[ZODB-Dev] How to do something similar to sql unique?

Paul Winkler pw_lists at slinkp.com
Wed Feb 9 11:00:15 EST 2005


On Wed, Feb 09, 2005 at 04:00:30PM +0100, Michael Zimmermann wrote:
> I hope this post
> 
> currently I am developing a small application used for bibliography 
> managment. There, publications are stored as objects of a publication 
> classs with the title, author.... as attributes to this object. For 
> storage the zodb is used.
> 
> Now, I do havethe following problem:
> For the ui I need to have a list of all authors (or titles or whatever), 
> i. e. something like the unique constraint available in sql.
> 
> To do this, do I have to iterate over all object, create a list of all 
> entry values and "uniquify" it?
> 
> Or what is the best solution for this problem?

A catalog. See lib/python/Products/ZCatalog in the Zope
sources. There's much zope-specific stuff in there
but AFAICT the base classes are intended to be usable in
a plain ZODB app as well. From Catalog.py:

class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
    """ An Object Catalog 

    An Object Catalog maintains a table of object metadata, and a
    series of manageable indexes to quickly search for objects
    (references in the metadata) that satisfy a search query.

    This class is not Zope specific, and can be used in any python
    program to build catalogs of objects.  Note that it does require
    the objects to be Persistent, and thus must be used with ZODB3.
    """

There are a bunch of nice indexes in lib/python/Products/PluginIndexes
but AFAICT they have a lot of zope dependencies.


-- 

Paul Winkler
http://www.slinkp.com


More information about the ZODB-Dev mailing list