[Zope] calling (SQL) methods dynamically from External methods

R. David Murray bitz@bitdance.com
Mon, 21 Aug 2000 13:47:47 -0400 (EDT)


On Mon, 21 Aug 2000, Philipp Auersperg wrote:
> Interesting fact:
> When retrieving the method object with "m=self.dbTest" and then with "m1=self.__dict__['dbTest']" 
> "print m,m1" show the same string but "m==m1" results to false!
> 
> What am I doing wrong? There seems something mixed up with namespaces, but I am too solly to solve it :(

I *think* what you are running into here is the difference between
an context-wrapped object and the unwrapped object.  I think __dict__
gets you the latter, but self.dbTest calls __getattr__ and the Zope
hook for that returns a wrapped object.  The wrapped object can
use acquisition to find the db connection, the unwrapped object can't.

As you found, getattr is the way to do what you want.

--RDM