[schooltool-dev] Deleting objects with ZEO
Brian Sutherland
jinty at web.de
Mon Jun 18 07:28:39 EDT 2007
On Mon, Jun 18, 2007 at 01:56:29AM -0400, Will Dickerson wrote:
> I am using a ZEO client with schooltool for use with my SIF Pull Agent. I'm
> using a simple dictionary as a queue in the ZODB, however when I attempt to
> delete items from the dictionary, the object inside of the database remains
> unchanged. Is there an extra step besides transaction.commit()?
Ok, so my ZODB-fu is not that good, but I'm pretty sure a normal
dictionary doesn't notify the Persistence machinery when it's been
changed.
Perhaps you can try using a btree dict of some sort:
from BTrees.IOBTree import IOBTree
from BTrees.OOBTree import OOBTree
queue = IOBTree()
This was pretty useful for me:
http://www.zope.org/Documentation/Books/ZDG/current/Persistence.stx
>
> >>> queue = openDb()['queue']
> >>> queue
> {'Hamburger': 'Foobar'}
> >>> queue.clear()
> >>> queue
> {}
> >>> transaction.commit()
> >>> closeDb()
> >>> queue = openDb()['queue']
> >>> queue
> {'Hamburger': 'Foobar'}
>
> The following is how I open and close the database in the real application.
>
> from ZODB import DB
> from ZEO import ClientStorage
>
> def openDb(self):
> storage = ClientStorage.ClientStorage(self.conf['dbName'])
> db = DB(storage)
>
> # open cursor and get root
> self.cx = db.open()
> self.dbroot = self.cx.root()
>
> stRoot = self.dbroot.setdefault('stAgent', {})
> stRoot.setdefault('queue', {})
>
>
> def closeDb(self):
> self.cx.close()
> _______________________________________________
> Schooltool-dev mailing list
> Schooltool-dev at schooltool.org
> http://lists.schooltool.org/mailman/listinfo/schooltool-dev
--
Brian Sutherland
More information about the Schooltool-dev
mailing list