problem with sort_order (when seting up zwikitracker)
I try to setup a zwikitracker. I did follow the instruction at zwiki.org. when I accsess the zwiki tracker I get the following error: The page I set up does not use sort_order anywhere. Any hints are apprechiated Robert Error Type: KeyErrorError Value: sort_order Traceback (innermost last): File /var/lib/Zope-2.4.4b1-linux2-x86/lib/python/ZPublisher/Publish.py, line 223, in publish_module File /var/lib/Zope-2.4.4b1-linux2-x86/lib/python/ZPublisher/Publish.py, line 187, in publish File /var/lib/Zope-2.4.4b1-linux2-x86/lib/python/Zope/__init__.py, line 226, in zpublisher_exception_hook (Object: Rottermann) File /var/lib/Zope-2.4.4b1-linux2-x86/lib/python/ZPublisher/Publish.py, line 171, in publish File /var/lib/Zope-2.4.4b1-linux2-x86/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: ZwikiTracker) File /var/lib/Zope-2.4.4b1-linux2-x86/lib/python/ZPublisher/Publish.py, line 112, in call_object (Object: ZwikiTracker) File /home/zope/Products/ZWiki/ZWikiPage.py, line 167, in __call__ (Object: ZwikiTracker) File /home/zope/Products/ZWiki/ZWikiPage.py, line 236, in render_structuredtextdtml (Object: ZwikiTracker) File /var/lib/Zope-2.4.4b1-linux2-x86/lib/python/OFS/DTMLDocument.py, line 199, in __call__ (Object: ZwikiTracker) File /var/lib/Zope-2.4.4b1-linux2-x86/lib/python/DocumentTemplate/DT_String.py, line 546, in __call__ (Object: ZwikiTracker) File /var/lib/Zope-2.4.4b1-linux2-x86/lib/python/DocumentTemplate/DT_Let.py, line 147, in render (Object: sortstart="_.string.find(QUERY_STRING,'sort_on')" sortend="_.string.find(QUERY_STRING,'&',sortstart)" sortend="(sortend != -1) and (sortend+1) or _.len(QUERY_STRING)" query="(sortstart == -1) and QUERY_STRING or (QUERY_STRING[:sortstart]+QUERY_STRING[sortend:])" query="query and ('&'+query) or ''" order="_.getattr(REQUEST,'sort_order','') and '&sort_order=' or '&sort_order=reverse'") File /var/lib/Zope-2.4.4b1-linux2-x86/lib/python/DocumentTemplate/DT_Util.py, line 231, in eval (Object: _.getattr(REQUEST,'sort_order','') and '&sort_order=' or '&sort_order=reverse') (Info: REQUEST) File <string>, line 2, in f File /var/lib/Zope-2.4.4b1-linux2-x86/lib/python/DocumentTemplate/DT_Util.py, line 153, in careful_getattr File /var/lib/Zope-2.4.4b1-linux2-x86/lib/python/AccessControl/DTML.py, line 101, in guarded_getattr (Object: ZwikiTracker) File /var/lib/Zope-2.4.4b1-linux2-x86/lib/python/AccessControl/ZopeGuards.py, line 109, in guarded_getattr File /var/lib/Zope-2.4.4b1-linux2-x86/lib/python/ZPublisher/HTTPRequest.py, line 897, in __getitem__ KeyError: (see above)
Aaah! Don't expose my dtml quackery here! Well, one or two others reported the same problem and I'd love to understand it. How can _.getattr(REQUEST,'sort_order','') ever give a KeyError ? puzzled, -Simon
Hi Simon, I was stumbling over that problem also and started to investigate it. The outcome is, that in Zope 2.4 getattr(REQUEST, variable, default) does not return the default but dies when variable does not exist. This "feature" was changed back to its expected behavior in 2.5 I checked 2.43 and 2.44b1 to test it just create a dtml method with: <dtml-var "_.getattr(REQUEST, 'abc', '')"> What I did to solve the problem is I changed al the "offending" dtl-code to python scripts where I first test for the existence of a key. That makes much nicer code anyhow. Robert ----- Original Message ----- From: "Simon Michael" <simon@joyful.com> To: <zope@zope.org> Sent: Sunday, February 24, 2002 5:02 AM Subject: [Zope] Re: problem with sort_order (when seting up zwikitracker)
Aaah! Don't expose my dtml quackery here!
Well, one or two others reported the same problem and I'd love to understand it. How can
_.getattr(REQUEST,'sort_order','')
ever give a KeyError ?
puzzled, -Simon
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Simon Michael writes:
Aaah! Don't expose my dtml quackery here!
Well, one or two others reported the same problem and I'd love to understand it. How can
_.getattr(REQUEST,'sort_order','')
ever give a KeyError ? I think, this is because "ZPublisher.HTTPRequest.HTTPRequest.__getattr__" was a bit carelessly mapped to the "__getitem__" method of this class which does not have a default attribute.
When I remember right, I saw a post that this careless mapping was fixed in recent Zope versions. You may use "REQUEST.get". I would prefer this anyway because "REQUEST" is basically a mapping. Exposing its keys as attributes, too, is just a convenience. As you experienced, it was not completely implemented. Dieter
participants (3)
-
Dieter Maurer -
Robert Rottermann -
Simon Michael