[Zope] Re: Generic add page template fails (solved)
Josef Meile
jmeile@hotmail.com
Tue, 22 Jul 2003 21:11:00 +0200
OK, I've solved it by using another way (details are below)
> I'm trying to do a generic add page template where I don't
> have to write the class name. The name will be taken from
> an attribute of the template object. If you see the file
> OFS/Image.py, you will see something like this:
>
>
manage_addImageForm=DTMLFile('dtml/imageAdd',globals(),Kind='Image',kind='im
age')
>
> The attribute Kind is called from OFS/dtml/imageAdd.dtml like this:
>
> <dtml-var "manage_form_title(this(), _,form_title='Add %s' %
> Kind,help_product='OFSP',help_topic='File_Add.stx')">
On my python class I put:
manage_addBoringForm=PageTemplateFile('ZPT/addBoring',globals())
manage_addBoringForm.Kind='Boring'
manage_addBoringForm._owner=None
And here is how I called it from the ZPT:
<h1 tal:define="pageTitle python:here.manage_form_title(here,
request,form_title='Add %s' % template.Kind)"
tal:replace="structure pageTitle">Add myClass
</h1>
...
<form action="someAction" method="post" enctype="multipart/form-data"
tal:define="formAction python:'manage_add'+template.Kind"
tal:attributes="action formAction">
...
My idea, as you see, is to write a macro that I can use from another
Products, which I will migrate from ZClasses to python based products.
Greetings,
Josef