access to old revisions of objects, even deleted ones
I have a need to access all revisions of objects of a certain type in my ZODB. It is straightforward enough to find all currently existing instances and then access each one's history. The problem with that approach is that it misses objects that have been deleted (but could still be brought back by an undo operation). Does anyone know a solution? I saw a thread in the ZODB-dev archive (http://aspn.activestate.com/ASPN/Mail/Message/zodb-dev/1414727) where Greg Ward of the MEMS Exchange offers a script that attempts to access all OIDs from zero up to DB.objectCount(), but for my ZODB it ran forever (apprently objectCount() returned a number greater than the actual number of objects in the storage). Later in that thread, Jeremy Hylton suggests that one can use the _index attribute of a FileStorage to obtain a list of existing OIDs, but other storages don't necessarily have _index, and I'd prefer to write something that will work with any undoable storage. Many thanks in advance, Sam Brauer ps. Maybe this message would be better posted on the ZODB list... I just thought I'd try the general list first.
Sam Brauer wrote at 2003-10-22 09:20 -0400:
I have a need to access all revisions of objects of a certain type in my ZODB. It is straightforward enough to find all currently existing instances and then access each one's history. The problem with that approach is that it misses objects that have been deleted (but could still be brought back by an undo operation).
Does anyone know a solution?
You know that deleted objects are finally removed by a pack? Maybe, you should avoid deletion altogether and emulate deletion be moving to a thrash bin. Dieter
Dieter Maurer wrote:
Sam Brauer wrote at 2003-10-22 09:20 -0400:
I have a need to access all revisions of objects of a certain type in my ZODB. It is straightforward enough to find all currently existing instances and then access each one's history. The problem with that approach is that it misses objects that have been deleted (but could still be brought back by an undo operation).
Does anyone know a solution?
You know that deleted objects are finally removed by a pack?
Maybe, you should avoid deletion altogether and emulate deletion be moving to a thrash bin.
Dieter
That doesn't really address what I'm trying to do. I want deleted objects to eventually disappear due to packing. The "problem" is that I have certain objects that refer to files on the filesystem (sort of like External File). Unlike External File, my objects never delete their files from the filesystem, even when the objects are deleted. This is intentional... so that if a deletion is undone, the file it refers to will still exist. The problem is that I want to clean up the files that are truly orphaned (not even referred to by an unpacked deleted object). I have a sort of mark-and-sweep based script that should do the job OK, but I think it would be nicer if I could just check the zodb to see if there are any objects at all (even deleted ones) that refer to a particular file. Besides, I'm also curious to know what sort of info I can access in a zodb about old transactions and the objects they operated on. - Sam - Sam
participants (2)
-
Dieter Maurer -
Sam Brauer