[Zope-dev] Put an adapted object in context

Martijn Faassen faassen at infrae.com
Fri Feb 13 05:30:43 EST 2004


Santi Camps wrote:
> 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.  

Okay, though Acquisition.Implicit is actually going to make your namespace
issues worse; better use Acquisition.Explicit and enjoy another benefit of
adapters -- namespace separation. I suspect though that your application's 
goals/design are different than mine. I appreciate adapters in part because
they can support a much cleaner partioning of code, while you're interested
in them primarily for the added dynamism, which is of course another major
benefit of them.

> > 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
> __bobo_traverse__).

Sounds a bit like views (which is a special kind of adapter in a way); what're
the adapters doing? 

A registry that maps meta_type to views is what we've been using inside Silva for
a long time, but we're going to move away from this towards mapping interface
to views/adapters, like in Zope 3, hopefully soon.

One important idea is that an object can have multiple views simultaneously,
instead of one big view standing in for all aspects of looking at the object. 
Associating views with interfaces makes it possible to associate some views for
the 'base interfaces' of an object (and thus for a large class of objects) while
others only apply to very particular interfaces (and thus a much smaller class
of objects).

Regards,

Martijn




More information about the Zope-Dev mailing list