[Zope] acquire using object reference

Casey Duncan c.duncan@nlada.org
Fri, 19 Oct 2001 09:31:12 -0400


On Friday 19 October 2001 06:07 am, kosh@aesaeion.com allegedly wrote:
> I have an object where all the acquisition wrappers where stripped earlier
> and I would like to acquire it in the context of another object which does
> have its wrappers.
>

You can rewrap an object (in external code) using the __of__ method provided 
by the acquisition mix-in classes. For example:

unwrapped = ob.aq_base
rewrapped = unwrapped.__of__(new_aq_parent)

rewrapped will then be the object (ob) with new_aq_parent as its acquisition 
parent.

So probably in your case you could do:

new_wrapper = 
wrapped_ob.aq_base.__of__(unwrapped_ob.__of__(wrapped_ob.aq_parent))

Which would insert the unwrapped object in the aq chain between the wrapped 
object and its current aq parent.

new_wrapper would then acquire from unwrapped_ob as well as its original 
parent.

hth,
/---------------------------------------------------\
  Casey Duncan, Sr. Web Developer
  National Legal Aid and Defender Association
  c.duncan@nlada.org
\---------------------------------------------------/