[Zope] adding dtml/zpt methods to product classes
Keith Alperin
kalperin at mac.com
Fri Jan 28 11:39:38 EST 2005
You understood the question perfectly; this is exactly what i was
looking for. I'm not sure where I got the idea of making those methods
instance variables, but once I started, I never even looked for a
better (even standard!) alternative. Thank you (and Pascal Peregrina
who gave the same answer) for your help!!
Sincerely,
Keith Alperin
On Jan 27, 2005, at 11:23 PM, Paul Winkler wrote:
> On Thu, Jan 27, 2005 at 09:59:17PM -0600, Keith Alperin wrote:
>> Greetings Zopistas!
>>
>> I have been a Zope tinkerer for a few years and have never been able
>> to
>> adequately solve this problem: When I create a Product class with
>> DTML/ZPT methods, how can I make those methods members of the class
>> rather than simply instance methods? These examples should illustrate
>> what I mean.
>
> I feel like I must be misunderstanding the question.
> Your examples are so odd, you must be trying to do something
> unusual ;-)
>
> But if you're asking what I think you're asking,
> just do what nearly ever other zope Product on the planet does:
>
> class Foo(SimpleItem):
>
> my_method1 = DTMLFile('dtml/my_method', globals())
>
> my_method2 = PageTemplateFile('zpt/my_other_method', globals())
>
> In other words, set them as class attributes, not within
> another method.
>
> And to secure them, do this:
>
> class Foo2(SimpleItem):
>
> security = AccessControl.classSecurityInfo()
>
> security.declareProtected('Some Permission', 'method1')
> method1 = PageTemplateFile('zpt/method1', globals())
>
> security.declarePrivate('method2')
> method2 = PageTemplateFile('zpt/method1', globals())
>
> security.declarePublic('method3')
> method3 = PageTemplateFile('zpt/method3', globals())
>
> --
>
> Paul Winkler
> http://www.slinkp.com
> _______________________________________________
> 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