[Zope] Passing keyword options to PageTemplateFile?
Jon Whitener
wmmail@twmi.rr.com
Wed, 12 Feb 2003 13:34:00 -0500
I'm creating a Python product ('MyClass') and attempting to use Zope
Page Templates for the 'manage_*' forms. In my manage_addMyClassForm, I
want the ZPT to render a multiple selection list (of 'categories') using
a tal:repeat statement which accesses 'categories' through the 'options'
ZPT name.
My problem lies in passing the 'categories' sequence into the ZPT (via
'options') from the MyClass.py module. Here's what I have so far:
- MyClass directory which contains __init__.py, MyClass.py, and a
sub-folder ('www') which contains the ZPT forms.
- MyClass.py defines MyClass and the 'categories' sequence (at the
global level). It also instantiates a Page Template object like so:
preAddForm = PageTemplateFile('www/manage_addMyClassForm', globals())
- Then, I attempt (and fail) to create my manage_addMyClassForm Page
Template this way (trying to use PageTemplate.__call__):
manage_addMyClassForm = preAddForm(categories = allCategories)
My intention is that the above line passes 'categories' into the Page
Template as one of the 'options' keyword arguments so that I can repeat
over the sequence like:
tal:repeat="category options/categories"
It doesn't work and I thank you in advance if you have any advice.
Below is the error I get when I start up Zope and it fails to import the
product:
2003-02-12T13:13:29 ERROR(200) Zope Could not import Products.MyClass
Traceback (innermost last):
File C:\Zope1\lib\python\OFS\Application.py, line 541, in import_product
File C:\Zope1\Products\MyClass\__init__.py, line 1, in ?
File C:\Zope1\Products\MyClass\MyClass.py, line 42, in ?
(Object: PageTemplate)
File C:\Zope1\lib\python\Shared\DC\Scripts\Bindings.py, line 252, in
__call__
(Object: manage_addMyClassForm)
File C:\Zope1\lib\python\Shared\DC\Scripts\Bindings.py, line 281, in
_bindAndExec
(Object: manage_addMyClassForm)
File <string>, line 1, in ?
File C:\Zope1\lib\python\Shared\DC\Scripts\Bindings.py, line 232, in
_getTraverseSubpath
(Object: manage_addMyClassForm)
AttributeError: other
Jon Whitener
Detroit Michigan USA