[ZODB-Dev] I would like append an indexer with uuid key at root of my ZODB, how can I append an function to commit event to update this uuid catalog ?
Hi, I use ZODB to record some Resources. All my Resources have an uuid field. All work well but I would like append a BTree to ZODB root object to index uuid of all my resources. I would like record to this BTree index only Resources commited to ZODB database. How can I connect a function to commit event ? In this function, how can I found all object modified ? How can I found all object removed to the database ? Other question : are there already a package to perform this task ? Thanks for your help, Stephane -- Stéphane Klein steph...@harobed.org blog: http://stephane-klein.info Twitter: http://twitter.com/klein_stephane pro: http://www.is-webdesign.com ___ 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
Re: [ZODB-Dev] I would like append an indexer with uuid key at root of my ZODB, how can I append an function to commit event to update this uuid catalog ?
I use ZODB to record some Resources. All my Resources have an uuid field. All work well but I would like append a BTree to ZODB root object to index uuid of all my resources. I would like record to this BTree index only Resources commited to ZODB database. How can I connect a function to commit event ? In this function, how can I found all object modified ? How can I found all object removed to the database ? Other question : are there already a package to perform this task ? The matching package is zope.catalog. It provides all you need (catalog and indexes) to handle your task. Objects creations and modifications are followed automatically by several subscribers as soon as this package is correctly registered. z3c.catalog and hurry.query packages can be good extensions packages to look at... Regards, Thierry ___ 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
Re: [ZODB-Dev] I would like append an indexer with uuid key at root of my ZODB, how can I append an function to commit event to update this uuid catalog ?
Hi Stéphane, Maybe this will be helpful: http://www.zodb.org/documentation/articles/ZODB2.html#persistent-aware-types I think what you are looking for is an OOBTree with the key being your uuid and the value being the path to your Resources object. def get_uuid(uuid, context): resource_path = context.my_btree.get(uuid, None) if uuid is not None: return context.unrestrictedTraverse(resource_path) You can get the path of an object in OFS by calling absolute_url method of that object. Hope this helps, Alex. On 28 June 2011 12:10, Stéphane Klein steph...@harobed.org wrote: Le 28/06/2011 10:21, Thierry Florac a écrit : I use ZODB to record some Resources. All my Resources have an uuid field. All work well but I would like append a BTree to ZODB root object to index uuid of all my resources. I would like record to this BTree index only Resources commited to ZODB database. How can I connect a function to commit event ? In this function, how can I found all object modified ? How can I found all object removed to the database ? Other question : are there already a package to perform this task ? The matching package is zope.catalog. It provides all you need (catalog and indexes) to handle your task. Objects creations and modifications are followed automatically by several subscribers as soon as this package is correctly registered. z3c.catalog and hurry.query packages can be good extensions packages to look at... I've already looked zope.catalog and repoze.catalog. Question : I haven't docid, can I use uuid here ? but it isn't the feature I want : I would like retrieve my object from uuid. Do you have an example of code about it ? More information about my aim : root (ZODB) uuid = { uuid_value1: resource_A, uuid_value2: resource_B, ... } folder_1 resource_A folder_2 resource_B I would like this function : get_by_uuid(uuid_value1) = return resource_A Regards, Stephane -- Stéphane Klein steph...@harobed.org blog: http://stephane-klein.info Twitter: http://twitter.com/klein_stephane pro: http://www.is-webdesign.com ___ 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 ___ 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
Re: [ZODB-Dev] I would like append an indexer with uuid key at root of my ZODB, how can I append an function to commit event to update this uuid catalog ?
Le 28/06/2011 10:21, Thierry Florac a écrit : I use ZODB to record some Resources. All my Resources have an uuid field. All work well but I would like append a BTree to ZODB root object to index uuid of all my resources. I would like record to this BTree index only Resources commited to ZODB database. How can I connect a function to commit event ? In this function, how can I found all object modified ? How can I found all object removed to the database ? Other question : are there already a package to perform this task ? The matching package is zope.catalog. It provides all you need (catalog and indexes) to handle your task. Objects creations and modifications are followed automatically by several subscribers as soon as this package is correctly registered. z3c.catalog and hurry.query packages can be good extensions packages to look at... In repoze.catalog documentation, I read : Note that when you call index_doc, you pass in a docid as the first argument, and the object you want to index as the second argument. When we index the peach object above we index it with the docid 1. Each docid must be unique within a catalog; when you query a repoze.catalog catalog, you’ll get back a sequence of document ids that match the query you supplied, which you’ll presumably need to map back to the content object in order to make sense of the response; you’re responsible for keeping track of which objects map to which document id yourself. Url : http://docs.repoze.org/catalog/overview.html#indexing you’re responsible for keeping track of which objects map to which document id yourself. = it is this part I would like to implement. Regards, Stephane -- Stéphane Klein steph...@harobed.org blog: http://stephane-klein.info Twitter: http://twitter.com/klein_stephane pro: http://www.is-webdesign.com ___ 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
Re: [ZODB-Dev] I would like append an indexer with uuid key at root of my ZODB, how can I append an function to commit event to update this uuid catalog ?
you’re responsible for keeping track of which objects map to which document id yourself. = it is this part I would like to implement. Maybe this will help: http://static.repoze.org/catalogdocs/overview.html#indexing But, as Alexandru suggests, maybe an OOBTree would be enough for your case. Cheers, Pedro -- José Pedro Ferreira Software Developer, Indico Project http://indico-software.org +---+ + '``'--- `+ CERN - European Organization for Nuclear Research + |CERN| / + 1211 Geneve 23, Switzerland + ..__. \. + IT-UDS-AVC + \\___.\ + Office: 513-1-005 + /+ Tel. +41227677159 +---+ ___ 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
Re: [ZODB-Dev] I would like append an indexer with uuid key at root of my ZODB, how can I append an function to commit event to update this uuid catalog ?
Le 28/06/2011 11:25, Pedro Ferreira a écrit : you’re responsible for keeping track of which objects map to which document id yourself. = it is this part I would like to implement. Maybe this will help: http://static.repoze.org/catalogdocs/overview.html#indexing It's the same doc that I send in my previous mail. -- Stéphane Klein steph...@harobed.org blog: http://stephane-klein.info Twitter: http://twitter.com/klein_stephane pro: http://www.is-webdesign.com ___ 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
Re: [ZODB-Dev] I would like append an indexer with uuid key at root of my ZODB, how can I append an function to commit event to update this uuid catalog ?
It's the same doc that I send in my previous mail. Oh sorry... anyway, why don't you store this UIID in the object itself? Then you can just retrieve the UUIDs of any result set in O(n). Cheers, Pedro -- José Pedro Ferreira Software Developer, Indico Project http://indico-software.org +---+ + '``'--- `+ CERN - European Organization for Nuclear Research + |CERN| / + 1211 Geneve 23, Switzerland + ..__. \. + IT-UDS-AVC + \\___.\ + Office: 513-1-005 + /+ Tel. +41227677159 +---+ ___ 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
Re: [ZODB-Dev] I would like append an indexer with uuid key at root of my ZODB, how can I append an function to commit event to update this uuid catalog ?
In repoze.catalog documentation, I read : Note that when you call index_doc, you pass in a docid as the first argument, and the object you want to index as the second argument. When we index the peach object above we index it with the docid 1. Each docid must be unique within a catalog; when you query a repoze.catalog catalog, youll get back a sequence of document ids that match the query you supplied, which youll presumably need to map back to the content object in order to make sense of the response; youre responsible for keeping track of which objects map to which document id yourself. Url : http://docs.repoze.org/catalog/overview.html#indexing youre responsible for keeping track of which objects map to which document id yourself. = it is this part I would like to implement. This last part is handled by zope.intid package, which is used internally by zope.catalog. When a persistent IntId utility has been created and registered, you can do what you need : - get a unique ID (an integer) for a given object (when persisted !) - get an object for a given ID Regards, Thierry ___ 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
Re: [ZODB-Dev] I would like append an indexer with uuid key at root of my ZODB, how can I append an function to commit event to update this uuid catalog ?
Le 28/06/2011 13:13, Thierry Florac a écrit : In repoze.catalog documentation, I read : Note that when you call index_doc, you pass in a docid as the first argument, and the object you want to index as the second argument. When we index the peach object above we index it with the docid 1. Each docid must be unique within a catalog; when you query a repoze.catalog catalog, you’ll get back a sequence of document ids that match the query you supplied, which you’ll presumably need to map back to the content object in order to make sense of the response; you’re responsible for keeping track of which objects map to which document id yourself. Url : http://docs.repoze.org/catalog/overview.html#indexing you’re responsible for keeping track of which objects map to which document id yourself. = it is this part I would like to implement. This last part is handled by zope.intid package, which is used internally by zope.catalog. When a persistent IntId utility has been created and registered, you can do what you need : - get a unique ID (an integer) for a given object (when persisted !) - get an object for a given ID I'm not in zope environment, I use Pyramid + ZODB. Can I use easily this tools in my context ? Regards, Stephane -- Stéphane Klein steph...@harobed.org blog: http://stephane-klein.info Twitter: http://twitter.com/klein_stephane pro: http://www.is-webdesign.com ___ 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
Re: [ZODB-Dev] I would like append an indexer with uuid key at root of my ZODB, how can I append an function to commit event to update this uuid catalog ?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 06/28/2011 05:21 AM, Stéphane Klein wrote: In repoze.catalog documentation, I read : Note that when you call index_doc, you pass in a docid as the first argument, and the object you want to index as the second argument. When we index the peach object above we index it with the docid 1. Each docid must be unique within a catalog; when you query a repoze.catalog catalog, you’ll get back a sequence of document ids that match the query you supplied, which you’ll presumably need to map back to the content object in order to make sense of the response; you’re responsible for keeping track of which objects map to which document id yourself. Url : http://docs.repoze.org/catalog/overview.html#indexing you’re responsible for keeping track of which objects map to which document id yourself. = it is this part I would like to implement. repoze.catalog ships with a 'DocumentMap' which can generate and track the docis for you. Tres. - -- === Tres Seaver +1 540-429-0999 tsea...@palladion.com Palladion Software Excellence by Designhttp://palladion.com -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEUEARECAAYFAk4JypkACgkQ+gerLs4ltQ4i4QCXfmxdKLy2nJ3CgdZQeF+Li14F twCdGKTNvpv8A8/dn7ThUAlgjkURkNw= =50dg -END PGP SIGNATURE- ___ 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
Re: [ZODB-Dev] I would like append an indexer with uuid key at root of my ZODB, how can I append an function to commit event to update this uuid catalog ?
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