10 Feb
2004
10 Feb
'04
10:12 a.m.
From: "Santi Camps" <santi@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.