[ZODB-Dev] I need disconnected mode functionality, but i get ClientDisconnected exception

Tim Peters tim.one at comcast.net
Tue Jan 31 17:01:30 EST 2006


[Mihai Ilinca]
> I want to have a ClientStorage that would work in both connected and
> disconnected (to zeo-server) mode. When zeo-server is not up (or
> reachable), I would like ClientStorage to use a local cache. Is that
> possible with ZEO?

To the _extent_ possible, yes.  A cache is not a database (it's "just a
cache"), and you'll get ClientDisconnected whenever you try something that
requires a database:

- You try to commit a transaction that modified an object.

- You try to load an object whose current state is neither in the
  connection's ZODB memory cache nor in the ZEO client's file cache.

To prevent all possible occurrences of the latter, you would have to, while
ZEO is connected, load the current revision of every object in the database,
and ensure that the ZEO file cache is large enough to hold the current
states of all objects in the database simultaneously.

> Right now I instanciate ClientStorage with ClientStorage(
>                                 zeoServerAddress,
>                                 name = 'name',
>                                 client = 'client',
>                                 var = 'path',
>                                 wait = False
> 	)
> When I try to access the attributes of the root persistent object
> (instance of PersistentMapping) I get a ClientDisconnected exception:

That's expected and unavoidable if, and only if, the states of the objects
to which those attributes are bound don't happen to be in the ZEO cache.
They only way they can get _into_ the ZEO cache is by loading those objects
while the ZEO client is connected.

...

> I know that the client is disconnected, as zeo-server is not up, but how
> can I make it so that I won't get this exception anymore, but instead
> have ZEO read the persistent objects from the local cache, transparently?

It already does that:  if the object states were in the ZEO cache, you would
not have seen ClientDisconnected.  When the object states are not in the ZEO
cache, then a connection to a ZEO server is necessary to fetch the states.

Or there's a bug of some kind.  That's possible, but unlikely given that
nobody else has had a similar complaint or question lately.




More information about the ZODB-Dev mailing list