IndexedCatalog is an extension to the Zope Object Database (ZODB)IndexedCatalog is licensed under the Lesser GNU Public Licence (LGPL).
that provides indexing and allows queries for objects based on attributes.
Which is accomplished by indexing all fields by type (string/integer/float) and
by a simple query language.
The IndexedCatalog does not require any additional extensions apart from
the ZODB, and it made for applications that use StandaloneZODB and not
Zope. It is completely untested with Zope at this time.
- Provides a Shelf, which aggregates queries and is a front-end to all IC features.
- Provides a Catalog class that stores objects and offers a query interface.
- Provides Indexes for Strings, Floats, Integers, Dates and Instances.
- Requires very little change to objects for catalogs and indexes to work: basically inherit from IndexedCatalog.IndexedObject, add some special attributes to the Classes, and use catalog.insert() to add the instances to the catalogs.
- Supports composite objects, initializing and indexing sub-objects automatically.
- Supports queries by type, and allows querying sub-object or referenced object attribute values.
- Allows ordering query results by field, both ascending and descending.
- Using Distutils means miminal effort to install.
from IndexedCatalog import attr, Catalog, IndexedObject
# Define the Object, it must inheirit from
# (IndexedCatalog.)IndexedObject
#
# Also create a field (attr) of IntType
class Object(IndexedObject):
_ic_options = [attr("attr", int)]
# Create a catalog, pass the class as argument to the
# constructor
catalog = Catalog(Object)
# Create 20 sample objects
for i in range(20):
obj = catalog.new()
obj.attr = i
# Do a simple query of all objects, that has
# attr higher or equal to 16
results = catalog.query('attr >= 16')
for result in results.sort('attr'):
print result, result.attr
More examples (which also can be found in the distribution):
- nhl.py: A larger, but still simple example, closer to a real world application.
- subclass.py: Subclasses, demonstrates a new feature in IndexedCatalog 0.5.0.
- local_transactions.py: Local transactions, this requires ZODB 3.2 alpha 1 or newer.
We now have a mailing list, for information about how to subscribe, go here. List archives can be found here.
There is also an irc channel #async on freenode. If you have any questions, feel free to join and we'll do our best to help you.
The latest version is 0.6.0 (released 9 October). Download it from here.For other formats, including zip and rpms, check out the dist/ directory
Check the instructions for
retrieving modules from Async Open Source's CVS server. The relevant
module name is IndexedCatalog