[Zope] Namespaces, ZPublisher, DocumentTemplate question
Andreas Kostyrka
andreas@kostyrka.priv.at
22 Sep 2002 19:18:14 +0200
Hi!
I've got a product that inherits from Folder, and creates
some magic "content" by overriding __bobo_traverse__.
Now I've got the problem that I cannot access the "magic" items from
within a DocumentTemplate like in <dtml-var special>.
The interesting thing is, that I've overloaded __getattr__ and
__getitem__, and it seems both are never called. (Actual code snippets
at the end)
So I'm wondering how DocumentTemplates (and say Page Templates) access
the items and properties?
Andreas
code snippet:
def __getattr__(self,k,*args):
r=Folder.Folder.__getattr__(self,k,*args)
print "__getattr__(%r,%r)==%r" % (self,key,r)
return r
def has_key(self,key):
r=Folder.Folder.has_key(self,key)
print "%r.has_key(%r)==%r" % (self,key,r)
return r
def __getitem__(self,key):
print "__getitem__(%r,%r)" % (self,key)
try:
return Folder.Folder.__getitem__(self,key)
except KeyError:
try:
return self.__bobo_traverse__(self,None,key)
except AttributeError:
raise KeyError,key