Inserting objects in acquisition chain
Hi, in a python product, I want to insert an (folderish) object into the namespace like this: parent_object subobject Now I want that parent_object behave like subobject would be it's sq_parent, all other things should stay the same (acquisition from objects higher in the tree etc...). No other bells and whistles needed, I need exactly what I depicted above. Any hints? cheers, oliver
Oliver Bleutgen writes:
in a python product, I want to insert an (folderish) object into the namespace like this:
parent_object subobject
Now I want that parent_object behave like subobject would be it's sq_parent, all other things should stay the same (acquisition from objects higher in the tree etc...).
No other bells and whistles needed, I need exactly what I depicted above. Have a look at "TransparentFolder" or my product "Mirroring Folder".
Neither does, what you want but you can see how to achieve this... Dieter
Casey, Dieter thanks for your answer. Dieter wrote:
Have a look at "TransparentFolder" or my product "Mirroring Folder".
Neither does, what you want but you can see how to achieve this...
Hmm, I looked at similiar products before asking this, but I don't think they do what I want. TransparentFolder patches zope, I would like to avoid that. As far as I understand, your Mirroring Folder doesn't insert an object into the namespace, it appends it. What I want to do is something like Casey wrote:
Assuming you want the effect to be temporary, that is only within the product code, you can do:
new_wrapper = subobject.aq_base.__of__(parent_object)
If subobject is not already an acquisition wrapper then this would do: new_wrapper = subobject.__of__(parent_object)
But I want it permanently. And that was what I'm trying to do (unsuccessfully) for a while, overriding __of__: [...] __old_of__ = Folder.__of__ def __of__(self,parent): t = getattr(self,'subfolder') wrapped_template = t.aq_base.__of__(parent) wrapped_self = self.__old_of__(wrapped_template) return wrapped_self The product inherits from OFS.Folder, subfolder is a plain folder. It doesn't work, trying to get any attribut of an instance gives an unauthorized error (sorry for the wrapping) [...] File /home/bleutgen/bin/Zope-2.4.3b1-src/lib/python/AccessControl/ZopeGuards.py, line 103, in aq_validate (Object: testordner) File /home/bleutgen/bin/Zope-2.4.3b1-src/lib/python/AccessControl/SecurityManager.py, line 149, in validate File /home/bleutgen/bin/Zope-2.4.3b1-src/lib/python/AccessControl/ZopeSecurityPolicy.py, line 229, in validate Unauthorized: (see above)
On Tuesday 13 November 2001 07:49 pm, Oliver Bleutgen allegedly wrote:
Hi,
in a python product, I want to insert an (folderish) object into the namespace like this:
parent_object subobject
Assuming you want the effect to be temporary, that is only within the product code, you can do: new_wrapper = subobject.aq_base.__of__(parent_object) If subobject is not already an acquisition wrapper then this would do: new_wrapper = subobject.__of__(parent_object)
Now I want that parent_object behave like subobject would be it's sq_parent, all other things should stay the same (acquisition from objects higher in the tree etc...).
No other bells and whistles needed, I need exactly what I depicted above.
Any hints?
cheers, oliver
hth, /---------------------------------------------------\ Casey Duncan, Sr. Web Developer National Legal Aid and Defender Association c.duncan@nlada.org \---------------------------------------------------/
participants (3)
-
Casey Duncan -
Dieter Maurer -
Oliver Bleutgen