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

Passin, Tom tpassin at mitretek.org
Thu May 27 17:00:43 EDT 2004


> From: zope-bounces at zope.org [mailto:zope-bounces at zope.org] On 
> Behalf Of Alec Mitchell

> Which won't acquire anything but the method.  The reason I 
> want to avoid a 
> subclass or monkey patch is that I want to override what this 
> method does for 
> this one instance of an already populated acl_users without 
> changing it in 
> any other way.
> 

In Python, you can override a method of an instance just by assigning it
to another function, like this -

class Test1:
   def f1(self):
      return "f1() of Test1"

def f1():
   return "f1() of instance"

T1 = Test1()
T1.f1 = f1

Running this within the Python interpreter, try the following -

>>> T1.f1()
'f1() of instance'

Is this what you had in mind?

Cheers,

Tom P



More information about the Zope mailing list