[ZODB-Dev] Synchronizing Mirror Sites

Christian Reis kiko at async.com.br
Tue Jul 22 19:00:09 EDT 2003


On Tue, Jul 22, 2003 at 11:04:37AM -0400, Shane Hathaway wrote:
> class Foo:
> 
>     def setBar(self, b):
>         self.bar = b
>         log.add(self, 'setBar', b)
> 
> class ChangeLog:
> 
>     def __init__(self):
>         self.changes = {}
> 
>     def add(self, obj, method, *args):
>         self.changes[(obj, method)] = args
> 
>     def replay(self):
>         for (obj, method), args in self.changes.items():
>             getattr(obj, method)(*args)

This code is tricky because calling setBar() also updates the `local'
log (but since we iterate in a copy() of the items, it seems to work).

Interestingly enough, you were right: pickle doesn't like pickling
instance methods. However, the ZODB works with with them just fine.

Take care,
--
Christian Reis, Senior Engineer, Async Open Source, Brazil.
http://async.com.br/~kiko/ | [+55 16] 261 2331 | NMFL



More information about the ZODB-Dev mailing list