On Tue, Jun 28, 2011 at 3:50 AM, Stéphane Klein <steph...@harobed.org> wrote: > Hi, > > > I use ZODB to record some Resources. > > All my Resources have an "uuid" field.
What is this? An integer? If so, how many bits? A string? A common strategy is to use integers as ids. > All work well but I would like append a BTree to ZODB root object to > "index" uuid of all my resources. I assume "append" is a euphemism for insert an item, as the root object is a mapping object. > I would like record to this BTree index only Resources commited to ZODB > database. > > How can I connect a function to "commit" event ? You don't want to connect to any sort of commit event. Simply update your index as your application code adds, updates or removed objects. The updates to the index will only be saved if the transaction is committed. They will be automatically discarded if the transaction is aborted. > In this function, how can I found all object modified ? > How can I found all object removed to the database ? This is up to your application and requires and an application-level strategy. A common technique is to generate modification and removal events in your application and wire these up to the index via event subscribers. Also, note that objects are never explicitly removed from the database. Objects are explicitly removed from application containers and it is up to the application to decide if this is significant. > Other question : are there already a package to perform this task ? As others have pointed out, there are many. These are often called "catalogs". Note that these usually involved frameworks that address multiple related concerns: - Assignment of ids. Ids are used as compact representation of documents so they can be efficiently stored and looked in indexes. Typically, integers are used. - Indexing, possibly including management of multiple indexes together. Note that these indexes are often, even in the simple cases, more complex than simple BTrees, although they typically use BTrees. For example, indexes typically use forward and reverse mappings to facilitate inindexing without having to store old document values. - Events to signal when objects should be added, updated, or removed from the index(es). Jim -- Jim Fulton http://www.linkedin.com/in/jimfulton _______________________________________________ For more information about ZODB, see the ZODB Wiki: http://www.zope.org/Wikis/ZODB/ ZODB-Dev mailing list - ZODB-Dev@zope.org https://mail.zope.org/mailman/listinfo/zodb-dev