[Zope-dev] getPhysicalPath differs for function vs. __getattr__

John Ziniti jziniti@speakeasy.org
Thu, 06 Dec 2001 11:06:19 -0500


Sorry the subject is not so discriptive, but
here is the issue I am dealing with.  I wonder
whether this has to do with the way Zope deals
with objects or has something to do with Python:

I have an Python Product class "Object".  With
the following bits of code, I get different results
from a <dtml-var>, depending on what I use.

class Object(PropertyManager, Implicit, Item):
     def get_path(self):
         """Return a path to myself"""
         path=string.join(self.getPhysicalPath()[1:], '/')
         return path

     def __getattr(self, attr):
         """Return a path to myself"""
         if attr == 'path':
             path=string.join(self.getPhysicalPath()[1:], '/')
             return path
         else:
             raise AttributeError, attr

Now the following two dtml tags yield:

<dtml-var "get_path()"> => /path/to/object

<dtml-var "path"> => object

Hopefully you see what I mean.  Why does this happen?
Can I put it in the collector as a bug?

TIA,

Ziniti