getPhysicalRoot and <Special Object Used to Force Acquisition>
Hi Inside a Python product, I tried to access another object this way: self.restrictedTraverse('/Folder/Object') This worked fine until this evening, when I got an error 'Object not callable' The error was on Traversable.py, function unrestrictedTraverse, line 166 (Zope 2.4.3 (binary release, python 2.1, win32-x86), python 2.1.0, win32) self=self.getPhysicalRoot() When I printed type(self.getPhysicalRoot), I got: <Special Object Used to Force Acquisition>' (what's that???) This was for a while, I tried several ways to circumvent this problem, and I was happy when I found something that worked fine. But when I tried the original code again to post here, it worked fine (as usual!) and now type(self.getPhysicalRoot)=type <'Python Method'> (as should be, I guess) I swear I didnt change anything but a few lines on my product!!! Nor even restarted Zope, just refreshed my product. And it's my own local install, so nobody else was working at the same server. So I don't understand why it began to fail, and why it suddenly was working OK again... Gabriel Genellina Softlab SRL
Gabriel Genellina wrote:
self=self.getPhysicalRoot()
When I printed type(self.getPhysicalRoot), I got: <Special Object Used to Force Acquisition>' (what's that???)
Urm, I think you meant type(self.getPhysicalRoot())
But when I tried the original code again to post here, it worked fine (as usual!) and now type(self.getPhysicalRoot)=type <'Python Method'> (as should be, I guess)
If you get the object through a non-Acquisition wrapped context, you'll get <Special Object Used to Force Acquisition>, if you get it through an Acquisition wrapped context, you'll get what you expect.
I swear I didnt change anything but a few lines on my product!!!
And what were those lines ;-) cheers, Chris
Gabriel Genellina writes:
Inside a Python product, I tried to access another object this way:
self.restrictedTraverse('/Folder/Object')
This worked fine until this evening, when I got an error 'Object not callable' The error was on Traversable.py, function unrestrictedTraverse, line 166 (Zope 2.4.3 (binary release, python 2.1, win32-x86), python 2.1.0, win32)
self=self.getPhysicalRoot()
When I printed type(self.getPhysicalRoot), I got: <Special Object Used to Force Acquisition>' (what's that???) That tells the acquisition machinery to use acquisition to get at the object, even if this is an explicit acquisition wrapper. See documentation in "lib/Components/ExtensionClass/doc/acquistion.html" for details.
Is it possible that your object ("self") was not acquisition wrapped (i.e. used inside "__init__", "__setstate__" or "__getattr__")? Dieter
participants (3)
-
Chris Withers -
Dieter Maurer -
Gabriel Genellina