[Zope] Override a method of an instance in the ZODB?

Small Business Services toolkit at magma.ca
Thu May 27 16:19:39 EDT 2004

From: "Alec Mitchell" <apm13 at columbia.edu>
> Hello zope gurus,
> I'm wondering if it is possible to override a method on a single instance
> an object in the ZODB.  My suspicion is no, but it doesn't hurt to ask.
> Specifically, I've tried:
> def userFolderDelUsers(self, names):
>     pass
> from types import MethodType
> setattr(acl_users, 'userFolderDelUsers', MethodType(userFolderDelUsers,
> acl_users, acl_users.__class__))
> Which works fine until the transaction gets committed, at which point it
> with "TypeError: can't pickle function objects".  Which seems pretty much
> like a lost cause.  Can you only do this at the class level?  Is there an
> unrelated way to accomplish the same goal (overriding a method, without
> monkeypatching or subclassing)?

How about simple acquisition?


Folder A
   | --Method AAA
   | --Folder B
          |-- Method AAA

Method AAA in Folder B will be found by acquisition before Method AAA in
Folder A (assuming you set up the path that way).


More information about the Zope mailing list