[Zope] DTML into Python for Formulator
cgreen
cgreen@ttsg.com
Fri, 11 Jan 2002 12:37:22 -0500
Okay... I'll admit it: I'm one of those who only knows about Python
because of Zope.
I am working with Formulator, and need a method to return a list of
properties. I have DTML code
that returns the list
<dtml-call "REQUEST.set('tmp',{})">
<dtml-in
expr="_.sequence.sort(PARENTS[0].objectValues(['STX_Document']),
(('topic', 'nocase'), ('title', 'cmp'),) )">
<dtml-call "REQUEST['tmp'].update({topic:''})">
</dtml-in>
<dtml-in "REQUEST['tmp'].keys()">
<dtml-var sequence-item>
</dtml-in>
The values of the "topic" property are returned. But when called as an
override method for a Formulator MultiListField, I get this error:
Zope Error
Zope has encountered an error while publishing this resource.
Error Type: NameError
Error Value: global name 'REQUEST' is not defined
File /usr/local/Zope/lib/python/DocumentTemplate/DT_Util.py, line 231,
in eval
(Object: form.topic.render())
(Info: form)
File <string>, line 2, in f
(Object: guarded_getattr)
File /usr/local/Zope/lib/python/Products/Formulator/Field.py, line
178, in render
(Object: topic)
File /usr/local/Zope/lib/python/Products/Formulator/Field.py, line
156, in _render_helper
(Object: topic)
File /usr/local/Zope/lib/python/Products/Formulator/Widget.py, line
451, in render
File /usr/local/Zope/lib/python/Products/Formulator/Widget.py, line
376, in render_items
File /usr/local/Zope/lib/python/Products/Formulator/Field.py, line
107, in get_value
(Object: topic)
File /usr/local/Zope/lib/python/Products/Formulator/MethodField.py,
line 40, in __call__
File /usr/local/Zope-2.4.3-linux2-x86/lib/python/OFS/DTMLMethod.py,
line 192, in __call__
(Object: topics)
File
/usr/local/Zope-2.4.3-linux2-x86/lib/python/DocumentTemplate/DT_String.py,
line 546, in __call__
(Object: topics)
File /usr/local/Zope/lib/python/DocumentTemplate/DT_Util.py, line 231,
in eval
(Object: REQUEST.set('tmp',{}))
(Info: REQUEST)
File <string>, line 2, in f
(Object: guarded_getattr)
NameError: (see above)
Okay -- I can figure out that it's because there's environment
(namespace stuff) when DTML is called as a method that just
doesn't work. So it needs to be rewritten as a Python script, but I'm a
Python neophyte, so I'm asking (pleading.... begging....) for
help.
Thanx in advance