> Santi Camps wrote:
> > My problem is that the adapter object, and also the adapted object
> > contained in it, are out of publisher context or something like this.
> > For instance, absolute_url() methods doesn't work becouse REQUEST is not
> > defined.
> I'm not sure I understand what you mean; I don't understand why your
> adapted object would become detached from the original context.
It was a stupid question, I was applying the adapter before publishing
the object. Now I apply the adapter in __bobo_traverse__ and its
beginning to run OK.
> It looks like you're losing acquisition context. You put an object into
> acquisition context explicitly. Something along these lines:
> import Acquisition
> class MyAdapter(Acquisition.Explicit):
> def __init__(self, context):
> self.context = context
> def getAdapter(context):
> # create adapter for context, and wrap it explicitly in the acquisition
> # context
> return MyAdapter(context).__of__(context)
> This works to give the adapter among other things a security context,
> so you can call methods on the adapter from a page template, for instance.
> You can also get to REQUEST and such, though in this case I used explicit
> acquisition so you'll have to use self.aq_acquire.REQUEST, if I recall
> the syntax correctly.
Thats very interesting !! I was rewriting __getattr__ to allow the
adapter access adapted object attributes, but doing this way its clear
and easier. Inheriting from Acquisition Implicit and applying the
adapter using __of__ I obtain the same result and have less problems.
> P.S. In the course of the coming weeks I'll be backporting parts of Zope 3's
> component architecture, especially adapters, into Zope 2. Contact me if
> you're interested. I also expect I'll be making more noise about this in
> a few weeks.
Sure. Now my little adapters systems is beginning to work fine, and I
will move my application this way. I'm using a simple engine, a method
to define which adapters should be applied to each meta_type (this info
is stored in SESSION) and then this adapters are transparently applied
when accessing this kind of objects (writing some code in
Zope-Dev maillist - [EMAIL PROTECTED]
** No cross posts or HTML encoding! **
(Related lists -