[Zope] Developing customer customizable products

Peter Sabaini peter at sabaini.at
Fri Dec 5 08:11:56 EST 2003


Petter Holmström wrote:
> On pe, 2003-12-05 at 14:48, Petter Holmström wrote:
> 
>>On pe, 2003-12-05 at 13:03, Peter Sabaini wrote:
>>
>>>I'd provide a default DTMLMethod | PageTemplate file and check for a 
>>>ZODB based DTMLMethod | PageTemplate object
>>>
>>>Sth like
>>>
>>>def render(self, <request, args etc.>):
>>>     template = getattr(self, 'customized_pt', None)
>>>     if template is None:
>>>         template = self.default_pt
>>>     return template(<your arguments>)
>>
>>                           ^^^^                        
>>What kind of arguments are we talking about here?
>>
>>This code:
>>
>>def index_html(self, REQUEST):
>>  template = DTMLFile( 'dtml/my_dtml_file', globals() )
>>  return template(self, REQUEST) 
>>
>>results in the following error message:
>>
>>  Error Type: AttributeError
>>  Error Value: aq_parent
> 
> 
> I found a solution to the problem:
> 
> def index_html(self, REQUEST):
>   template = DTMLFile( self.private_views['view'], globals()
> ).__of__(self)
>   return template()
> 
> Now I just have to figure out why this works... :-)

Because the DTMLFile misses Acquisition wrappers otherwise.

I've always made the template a class attribute -- parsing DTML is a 
rather expensive process, and should be avoided unless necessary

Eg.

class MyProduct(...):
     template = DTMLFile('dtml/my_dtml_file', globals())
     def index_html(self, REQUEST):
         return self.template(client=self, REQUEST=REQUEST)




> 
> -Petter-
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3461 bytes
Desc: S/MIME Cryptographic Signature
Url : http://lists.zope.org/pipermail/zope/attachments/20031205/049a403a/smime.bin


More information about the Zope mailing list