[Zope] Adding attributes to PageTemplateFile
Josef Albert Meile
jmeile at hotmail.com
Fri Sep 12 10:34:06 EDT 2003
--- In zope at yahoogroups.com, Chris Withers <chrisw at n...> wrote:
>Carsten Gehling wrote:
> > I have a product in which I have the following constructor
> >
> > ------------------------------------
> > software_type_list = [
> > {'value': 'OS'},
> > {'value': 'Applikation'},
> > {'value': 'Service'}
> > ]
> >
> > manage_addSoftwareForm = PageTemplateFile("www/software_form_add",
> > globals())
>
>
> > Any ideas? TIA
>
>Simplest way I can think of is:
>
> software_type_list = [
> {'value': 'OS'},
> {'value': 'Applikation'},
> {'value': 'Service'}
> ]
>
> _addSoftwareForm = PageTemplateFile("www/software_form_add",
> globals())
>
> def manage_addSoftwareForm(self,*args,**kw):
> kw['software_type_list']=software_type_list
> return self._addSoftwareForm(*args,**kw)
There is one even much simpler. I've used it on my JMZPTMacros
product and it worked perfect:
manage_addSoftwareForm.software_type_list = [
{'value': 'OS'},
{'value': 'Applikation'},
{'value': 'Service'}
]
You don't have to define the method manage_addSoftwareForm as
previously suggested. You just create the attribute on the fly.
Then you can call it as an attribute of your ZPT. I have tested
it with simple types, but I think with a dictionary should work
too.
_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
More information about the Zope
mailing list