[ZODB-Dev] ZClients not updating
Greg Ward
gward@mems-exchange.org
Wed, 14 Nov 2001 13:40:38 -0500
On 14 November 2001, sean.upton@uniontrib.com said:
> No, my application does not use connection.sync() - yet; forgive my
> ignorance, but I'm assuming that this is done on each client? What I'm
> hoping for is invalidation messages from the ZSS to the clients; perhaps I'm
> hoping for too much?
The ZEO server does send invalidation messages, but your client will
only see them if it happens to use an asyncore main loop (which Zope
happens to do). My understanding is that asyncore has a mechanism where
you can register bits of code to handle certain events, and
ClientStorage registers some code to handle ZEO invalidation events. If
you're not running an asyncore main loop, that registration is useless.
The easy solution is to call connection.sync() when you think it might
be time to synchronize with the database. Our application is a web
site, so call connection.sync() at the start of each HTTP request --
ie. after some idle period -- rather than at the end of each HTTP
request, before some idle period. Think about it.
The hard solution would be to dig into ClientStorage and find out how to
recognize and respond to invalidation events from the server. Exercise
left for the reader. ;-)
Greg
--
Greg Ward - software developer gward@mems-exchange.org
MEMS Exchange http://www.mems-exchange.org