[Zope3-dev] persistence by adaptation, and aop?

Guido van Rossum guido@python.org
Tue, 03 Jun 2003 13:13:34 -0400


> I think it should be possible to achieve a similar effect to the 
> Persistent base class by using a proxy that rebinds the "self" of 
> methods and properties, and detects changes to the object.
> 
> So perhaps something like this:
> 
>    obj = SomeNonPersistentClass()
>    pobj = PersistenceProxy(obj)
>    pobj.doSomething()
> 
> The code to doSomething might look like this:
> 
>    class SomeNonPersistentClass:
> 
>      def doSomething(self):
>          self.foo = 'bar'
> 
> When doSomething() is called via the proxy, the 'self' argument is not 
> obj, but is instead another proxy around obj that hooks __setattr__ and 
> does the right things.

Only if the object implementation has no C code.

--Guido van Rossum (home page: http://www.python.org/~guido/)