[Zope] How to override DTMLFile? (solved)
Peter Bengtsson
mail@peterbe.com
Sat, 24 May 2003 14:38:31 +0100
At 10:34 2003-05-24 +0200, Johan Carlsson wrote:
>Peter Bengtsson wrote:
>>I got it!
>>class CTDTMLFile(DTMLFile):
>> def __init__(self, name, _prefix=None, **kw):
>> " doc string "
>> <do whatever needs to be done>
>> apply(DTMLFile.__init__, (self, name, _prefix), kw)
>> def _exec(self, bound_data, args, kw):
>> " doc string "
>> zope = bound_data['context']
>> <do whatever needs to be done>
>> return apply(DTMLFile._exec, (self, bound_data, args, kw))
>>
>>The aim of this hack is for me to be able to control whether DTML Methods
>>should be run from the filesystem or as DTML Method objects.
>>This will hopefully lead to a all-purpose product for whatever reasons
>>one might have.
>
>Cool, but what doe sit do?
Nothing. More important: What _can_ it do.
What I do with it is to keep track of which templates use the DTMLFile class.
>I suspect the "zope = bound_data['context']" is to get
>the current namespace for the "<do whatever needs to be done>" part in
>"_exec"?
>
>What is the bound_data anyway?
>And what is prefix?
Yes, bound_data['context'] == self
_prefix is what is sucked up when globals() is called.
>Johan Carlsson
>