On Mon, 09 Feb 2004 21:48:29 +0100
Santi Camps <[EMAIL PROTECTED]> wrote:

> Hi all,
> I know that adaptors are introduced in zope3 but, anybody knows if
> this technique can be used in zope2 ?

Adapters are a general pattern. Zope 3 has infrastructure (component
architecture and ZCML) that automates registering and using them, but
the general pattern can certainly be applied to Zope 2 without it. Just
create a class which defines the methods you want, and accepts a folder
in its constructor. When you want to use the adapter, instantiate the
class around the folder.
> I've been trying to add some extra functionallity to a Folder object
> without inheriting, but I'm not able to make it work.  To maintain the
> adapted object publishable I've rewrited __getattr__, but then some
> extra problems appears.  

__getattr__ hooks are notoriously tricky to get right, especially for
Zope due to acquisition and especially for folders.
> Anybody knows if there is a way to use adapters in zope2 ?  Or, if
> not, there is some other way to add functionallity on-the-fly, without
> inheriting ?

Zope2 folders are designed for this. They are really just "blank
objects" where you can specify your own methods in instance space.
Traditionally in Zope2, there are two ways to do this: by adding
"method" objects (External Methods, DTML methods, python scripts, ZPT)
directly to the folder. Or by adding these objects "above" the folders
and aquiring them which is a type of environmental inheritance. In the
CMF this is codified in the skins tool which contains global methods
which can be applied to basically any object in the site.



Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope )

Reply via email to