SV: [Zope] Adding attributes to PageTemplateFile

Carsten Gehling carsten at gehling.dk
Fri Sep 12 11:18:45 EDT 2003


I looked at your JMZPTMacros product, and I cannot find any code, that uses
the solution you presented.

Anyway it doesn't work. I've tried with the list of dictionaries AND also
tried with a simple string type instead. On both occasions I get an
"Attribute Error", meaning that Zope cannot find the specified attribute.

I use the reference "here/attribute-name". Should I use something else
instead of "here" ?

- Carsten


> -----Oprindelig meddelelse-----
> Fra: zope-bounces at zope.org [mailto:zope-bounces at zope.org]På vegne af
> Josef Albert Meile
> Sendt: 12. september 2003 09:34
> Til: zope at zope.org
> Emne: Re: [Zope] Adding attributes to PageTemplateFile
>
>
> --- 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
>
>
> _______________________________________________
> Zope maillist  -  Zope at zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )
>




More information about the Zope mailing list