[Zope] Re: [Zope-dev] Adapters in Zope 2

Lennart Regebro regebro at nuxeo.com
Tue Feb 10 05:12:10 EST 2004


From: "Santi Camps" <santi at zetadb.com>
> I've been trying to add some extra functionallity to a Folder object
> without inheriting, but I'm not able to make it work.

First question is "Why?". Unless you want to change the fucntionality of
*all* folder objects inheriting is the way to go.

> 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 ?

MonkeyPatching. Python is highly dynamic. You rewrite the methods to how you
would like them, and then you replace them with a quick.

  TheClass.OldMethod = NewMethod.

And now you call the new method with
  object = TheClass()
  object.OldMethod()
Very cool.




More information about the Zope mailing list