[Zope] Set "uncontained" attributes on a Implicitly
wrapped object.
Etienne Labuschagne
elabuschagne@gmsonline.co.za
Thu, 17 Jul 2003 19:30:03 +0200
Not quite sure what the end result is you want, or that I understand you
question - do you want it wrapped or not?
Anyway, to unwrap the object I do the following:
unwrappedOb = Acquisition.aq_base(wrappedOb)
unwrappedOb.someAttribute #this will now not traverse to the aq_parents to
search if this attr doesn't exist.
this is better than ob.aq_base as it works for "unwrapped" objects too
without raising an AttributeError if the ob doesn't have the aq_base.
To wrap the object with an acquisition context (not sure my lingo is
correct here), I've had joy with:
wrappedOb = Acquisition.ImplicitAcquisitionWrapper([unwrappedOb,self])
where self could be anything already Acquisition wrapped.
HTH
Etienne
At 06:36 PM 17/7/2003 +0200, Johan Carlsson wrote:
>I already found a solution for this but I'm asking to
>see if there might be another way to do this?
>
>I need to save a referens to a acquision wrapped object "Configure"
>in a object which at some point doesn't have it's own context (just a
>single wrapped object).
>
>I save this volatile and always uniquely for each REQUEST object (see CMF
>skinable for an example).
>
>Just assigning it to the attribute self._v_skinfolder=sf and the accessing
>it as self.skinfolder makes it contained in the object
>(aq_chain would say [<Skinfolder>, <Object>])
>
>But by saving it as a tuple: self._v_skinfolder=(sf,)
>it's not directly contained in the <Object> so when accessing
>it self.skinfolder[0] it's returned with its original context.
>
>Is there anyway to make uncontained attributes of an object
>that inherits Acquisision.Implicit?
>
>
>Cheers,
>Johan Carlsson
>
>
>
>--
>Johan Carlsson Tel: + 46 8 31 24 94
>Colliberty Mob: + 46 70 558 25 24
>Torsgatan 72 Email: johanc@easypublisher.com
>SE-113 37 STOCKHOLM
>
>
>
>_______________________________________________
>Zope maillist - Zope@zope.org
>http://mail.zope.org/mailman/listinfo/zope
>** No cross posts or HTML encoding! **
>(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
>http://mail.zope.org/mailman/listinfo/zope-dev )