[Zope-dev] Advice on DTMLDocument

Andy McKay andym@ActiveState.com
Thu, 14 Sep 2000 14:03:37 -0700


Hi there,

Well a while ago I came across a bug that I couldnt cut and paste and
object. A few people helped me out on that, thanks. Ive had a week of
squishing bugs and finally got to this one. The reason why? I was
subclassing DTMLDocument but using my own __init__ (similar to one where I
dont subclass from DTMLDocument), where I didnt fiddle with __name__. The
result was when absolute_url() was called I was getting:
http://fork:8080/code/test/ElementWithAttributes  !

Solutions I have found for this:
-    Dont subclass from DTMLDocument. This is not an option for me.
-    Dont try to use your own __init__, use DTMLDocument. This works great,
but now I have to recreate all my objects. My current scheme is create the
object in manage_addObject, let DTMLDocument do the __init__, then
manipulate it then and there in the manage_addObject.

Help would be appreciated on:
-    Why is this happening? A class fine breaks if you subclass
DTMLDocument, it would seem __name__ is being used some times, not in
others.
-    Is something funky happening in DTMLDocument __init__, which subclasses
DTMLMethod etc...?

Ive got a fix, but I only sort of know why and that bugs me.

Thanks.

--
  Andy McKay, Developer.
  ActiveState.