Test: Refer To Weblog Post

Can I refer to P99? Almost. Internally, it works fine. Externally, it's Just Plain Wrong. This might help... Attempt two... Three... Four... Five... Six...

Weird. Now it's the other way around; see P110, for which its link back here is external only.

I think it's a problem with the Mesh link caching combining with the internal and external rendering. The link to P110 above works fine internally, but referring to P99 again still targets external.

A useful helper script:

import xmlrpclib
s = xmlrpclib.Server('http://127.0.0.1:4334/RPC2')
u = 'garth'
p = '******'
print repr(s.weblog.listRegisteredFunctions())

If I python -i it, I can do this kind of thing:

>>> [i for i in s.mesh._dumpcontents(u,p)['items']
...  if i['homeTool']=='wiki' 
...  and i['uniqueId'].endswith('ReferToWeblogPost')]
[{'homeTool': 'wiki', 
  'handle': 306, 
  'uniqueId': 'Test/ReferToWeblogPost', 
  'exists': 1, 
  'uri': 'pyds:/wiki/Test/ReferToWeblogPost'}]

>>> import pprint
>>> pprint.pprint([l for l in s.mesh._dumpcontents(u,p)['links']
...  if l['originHandle'] == 306])
[{'originHandle': 306, 'destHandle':   321, 'linkText': 'p100'},
 {'originHandle': 306, 'destHandle': 0, 'linkText': 'p110'},
 {'originHandle': 306, 'destHandle': 302, 'linkText': 'p99'}]
>>>

>>> pprint.pprint([i for i in s.mesh._dumpcontents(u,p)['items']
... if i['handle']==302])
[{'exists': 1,
  'handle': 302,
  'homeTool': 'weblog',
  'uniqueId': 'P99',
  'uri': 'pyds:/weblog/P99'}]

Okay, so that reminds me that the URIs stored in MeshTool are private internal ones (which one day — assuming I don't drop off the earth again — I'll expose so people can see and edit the cached entries when they edit items).

My next guess is that either

  1. what I'm seeing displayed by the weblog tool is the cached version of the HTML fragment generated for uploading, or
  2. there's some problem with the context detection in... uh, somewhere. You know, I completely forget how this all works. I hope Georg figured it out before I forgot. :)

The problem with the first option is it doesn't explain why (internally) the link from here to P99 goes external whilst the link to P110 goes internal.

Later (P114):

I thought I was on to something, but WeblogTemplate.tmpl does indeed refer to the local rendering:

<td>%post.localrendered
<p align="right">%post.id, %post.pubdate</td>

Crummy HTML, but it's hitting .localrendered. Bah!

Back to my XML-RPC tester (see ReferToWeblogPost):

>>> s.weblog.getPost(u,p,'P112')['localrendered']
'<p>Following on from 
 <a class="weblog reference" 
  href="http://www.pycs.net/users/
  0000088/categories/PyDS/
  2004/05/24.html#P111">P111</a>; 
 if I hit the Status page I get a report 
 on the size of the StoryTool render 
 queue. Maybe it\'s there now?</p>\n'

It's the same as ['rendered']. So, I need to dig where those values are rendered.

>>> s.weblog.getRenderedTexts(u,p,t,1,'P112')
Traceback (most recent call last):
[...]
xmlrpclib.ProtocolError: <ProtocolError for 127.0.0.1:4334/RPC2: -1 >

Oh, that's no help. Dropping a call to PyDS.Tool.debugOutput in WeblogTool.getRenderedTexts is giving me some information, though. Definitely, I'm getting the same results from req.renderTextWithTraceback whether _flet.beginDesktop() has happened or not.

AHA! The problem is in MeshTool.StrayLinkResolver.resolveStrayLink, which should begin:

def resolveStrayLink(self, stray): 
        """Resolve a stray by consulting all tools capable of doing so."""
        # First, try the cache...
        previousDestination = self.itemLinks.setdefault(stray, 0)
        # side-effect of the above: sets dest to 0 if not found
        if previousDestination is not None: 
                # TODO: correctly handle the destination no longer existing,
                # as could/should be shown by thrown exceptions from 
                # getCloudLinkDetails. 
                if _flet.desktop:
                        return previousDestination.getDesktopDisplayLinkDetails()
                else: 
                        return previousDestination.getCloudLinkDetails()
        # Gather list of potential matches.

... and then continuing with the rest of the method from the comment onward. You'll also need to add this method to MeshTool.ItemDetail:

def getDesktopDisplayLinkDetails(self):
        "Get the display/edit link details for this item."
        tool = PyDS.Tool.getTool(self.homeTool)
        return tool.getDesktopDisplayLinkDetailsForUniqueId(self.uniqueId)

Sorry about that.

last change 2004-05-28 23:41:20

Garth is testing PyDS rather more extensively than at first he thought he would.

XML-Image Letterimage

© 2004, Garth T Kidd