[Zope-dev] dtml-try/except triggers namespace bug
Ng Pheng Siong
ngps@post1.com
Sun, 9 Jul 2000 00:02:18 +0800
Hi,
I've run into a bug with <dtml-try/except> with Zope 2.2.0b3.
I have a folder called 'root' that looks like this:
one (folder)
two (folder)
three (folder)
a_one (dtml method)
a_two (dtml method)
index_html (dtml method)
index_html looks like this:
<dtml-try>
<dtml-var "_.getitem('a_%s' % id, 1)">
<dtml-except KeyError>
Here goes default information.
</dtml-try>
The idea is to do the following:
http://.../root/one --> invoke root/a_one
http://.../root/two --> invoke root/a_two
http://.../root/one/two --> invoke root/a_two
http://.../root/two/one --> invoke root/a_one
http://.../root/three --> "Here goes default information."
http://.../root --> "Here goes default information."
I'm rendering the folders under root (one, two, three, ...) with
<dtml-tree>; I want to reconfigure my tree easily while keeping the
leaves' content in one place, i.e., in a_one, a_two, etc. in root.
The above works with Zope-2.1.6 but not with Zope-2.2.0b3.
Here's the traceback:
Zope has encountered an error while publishing this resource.
Error Type: TypeError
Error Value: unexpected keyword argument: error_type
Traceback (innermost last):
File C:\pkg\Zope220b3\lib\python\ZPublisher\Publish.py, line 222, in publish_module
File C:\pkg\Zope220b3\lib\python\ZPublisher\Publish.py, line 187, in publish
File C:\pkg\Zope220b3\lib\python\Zope\__init__.py, line 221, in zpublisher_exception_hook
(Object: ElementWithAttributes)
File C:\pkg\Zope220b3\lib\python\ZPublisher\Publish.py, line 171, in publish
File C:\pkg\Zope220b3\lib\python\ZPublisher\mapply.py, line 160, in mapply
(Object: index_html)
File C:\pkg\Zope220b3\lib\python\ZPublisher\Publish.py, line 112, in call_object
(Object: index_html)
File C:\pkg\Zope220b3\lib\python\OFS\DTMLMethod.py, line 167, in __call__
(Object: index_html)
File C:\pkg\Zope220b3\lib\python\DocumentTemplate\DT_String.py, line 502, in __call__
(Object: index_html)
File C:\pkg\Zope220b3\lib\python\DocumentTemplate\DT_Try.py, line 212, in render
File C:\pkg\Zope220b3\lib\python\DocumentTemplate\DT_Try.py, line 244, in render_try_except
File C:\pkg\Zope220b3\lib\python\DocumentTemplate\DT_Util.py, line 262, in namespace
TypeError: (see above)
Traceback says the problem is at DocumentTemplate.DT_Util.namespace().
The 2.1.6 and 2.2.0b3 implementations are different. Plugging in 2.1.6's
code fixes _this_ problem:
def namespace(self, **kw):
"""Create a tuple consisting of a single instance whos attributes are
provided as keyword arguments."""
#return apply(self, (), kw)
# XXX ngps - following is the 2.1.6 implementation
r=namespace_()
d=r.__dict__
for k, v in kw.items(): d[k]=v
return r,
Cheers.
--
Ng Pheng Siong <ngps@post1.com> * http://www.post1.com/home/ngps