Hello-- I'm having a problem with indirection. I have a form object that has a header method. I also have a DTML method called showForm: <dtml-var "form.header()"> The problem is that the name of the form object that I'm calling is variable. From all of the Zope docs and howtos, _[var] should allow you to do indirection. I'm putting the actual name of the form object as a parameter to showFormm so this should work: <dtml-var "_[form].header()"> But this gives me an AttributeError of __hash__ error with the following traceback: Traceback (innermost last): File /usr/local/zope/lib/python/ZPublisher/Publish.py, line 223, in publish_module File /usr/local/zope/lib/python/ZPublisher/Publish.py, line 187, in publish File /usr/local/zope/lib/python/Zope/__init__.py, line 221, in zpublisher_exception_hook (Object: Traversable) File /usr/local/zope/lib/python/ZPublisher/Publish.py, line 171, in publish File /usr/local/zope/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: index_html) File /usr/local/zope/lib/python/ZPublisher/Publish.py, line 112, in call_object (Object: index_html) File /usr/local/zope/lib/python/OFS/DTMLMethod.py, line 189, in __call__ (Object: index_html) File /usr/local/zope/lib/python/DocumentTemplate/DT_String.py, line 540, in __call__ (Object: index_html) File /usr/local/zope/lib/python/DocumentTemplate/DT_Util.py, line 339, in eval (Object: showForm(form=dumbform)) (Info: showForm) File <string>, line 0, in ? File /usr/local/zope/lib/python/OFS/DTMLMethod.py, line 182, in __call__ (Object: showForm) File /usr/local/zope/lib/python/DocumentTemplate/DT_String.py, line 540, in __call__ (Object: showForm) File /usr/local/zope/lib/python/DocumentTemplate/DT_Util.py, line 339, in eval (Object: _[form].header()) (Info: form) File <string>, line 0, in ? File /usr/local/zope/lib/python/DocumentTemplate/DT_Util.py, line 167, in careful_getitem AttributeError: (see above) I'm sure I'm missing something obvious here. Any ideas? Thanks, Jeremy. -------------------------------------------- Jeremy M. Smith <jeremy@ucdavis.edu> Technical Support Manager, Programmer University of California, Davis Languages and Literatures Language Learning Center
On Wed, Jan 30, 2002 at 03:44:51PM -0800, Jeremy M. Smith wrote:
<dtml-var "_[form].header()">
DTML Magic! _[form] is a string (rendered form). Use getitem(form, 0). 0 prevents rendering - you get the real object. Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd@phd.pp.ru Programmers don't die, they just GOSUB without RETURN.
Thanks very much for the tip . . . you put me on the right track. _.getitem(form,0) still gave an AttributeError: __hash__, but using _.getitem('form',0) works beautifully! Thanks again, Jeremy. On Thu, 31 Jan 2002, Oleg Broytmann wrote:
On Wed, Jan 30, 2002 at 03:44:51PM -0800, Jeremy M. Smith wrote:
<dtml-var "_[form].header()">
DTML Magic! _[form] is a string (rendered form). Use getitem(form, 0). 0 prevents rendering - you get the real object.
Oleg.
-- -------------------------------------------- Jeremy M. Smith <jeremy@ucdavis.edu> Technical Support Manager, Programmer University of California, Davis Languages and Literatures Language Learning Center
On Thu, Jan 31, 2002 at 09:24:16AM -0800, Jeremy M. Smith wrote:
_.getitem(form,0) still gave an AttributeError: __hash__, but using _.getitem('form',0) works beautifully!
Of course I was bitten by the DTML Magic, too! :))) Oleg. -- Oleg Broytmann http://www.zope.org/Members/phd/ phd@phd.pp.ru Programmers don't die, they just GOSUB without RETURN.
participants (2)
-
Jeremy M. Smith -
Oleg Broytmann