[Zope] How to override DTMLFile?

Pierre-Julien Grizel grizel@mouli.net
Fri, 23 May 2003 14:12:49 +0200 (CEST)


Hi,


You can have a look at our SkinMI product in
http://sourceforge.net/projects/ingeniweb which overrides DTMLFile - but
maybe not in the way you want to do.

Anyway, it may give you some clues...



Regards,


P.-J. Grizel
--
Ingeniweb
www.ingeniweb.com


> I want to override DTMLFile from Globals in my own special product. I
> managed to do this::
>
> class PeterDTMLFile(DTMLFile):
>      def foo(self):
>          return "works"
>
>
> Then from somewhere else I do::
>
> manage_edit = PeterDTMLFile('dtml/manage_edit', globals())
>
> This works but doing <dtml-var foo> raises a KeyError.
>
> I've looked at Localizer and how they override DTMLFile's __init__ and
> _exec method.
> But if I try to do::
>
> # pointless inheritance hack but for testing
> class PeterDTMLFile(DTMLFile):
>      def __init__(self, name, _prefix=None, **kw):
>          apply(DTMLFile.inheritedAttribute('__init__'),
>                (self, name, _prefix), kw)
>
> Which in effect is pretty pointless, I get the following error when
> trying  my manage_edit::
>
>
> Traceback (innermost last):
>    Module ZPublisher.Publish, line 98, in publish
>    Module ZPublisher.mapply, line 62, in mapply
> AttributeError: 'None' object has no attribute 'co_varnames'
>
>
> So, can anybody tell me how to override the DTMLFile class (and possible
>  also the PageTemplateFile)
>
> Grateful,
> Peter
>
>
> _______________________________________________
> Zope maillist  -  Zope@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 )