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.
Base Classes
|
|
Persistent
Acquisition.Implicit
ExtensionClass.Base
|
Methods
|
|
|
|
__getitem__
|
__getitem__ (
self,
index,
ttype=type(() ),
)
Returns instances of self._v_brains, or whatever is passed
into self.useBrains.
|
|
__init__
|
__init__ (
self,
vocabulary=None,
brains=None,
)
|
|
__setstate__
|
__setstate__ ( self, state )
initialize your brains. This method is called when the
catalog is first activated (from the persistent storage)
|
|
_indexedSearch
|
_indexedSearch (
self,
args,
sort_index,
append,
used,
IIBType=type(IIBucket() ),
intSType=type(intSet() ),
)
Iterate through the indexes, applying the query to each one.
Do some magic to join result sets. Be intelligent about
handling intSets and IIBuckets.
|
|
addColumn
|
addColumn (
self,
name,
default_value=None,
)
adds a row to the meta data schema
Exceptions
|
|
'Column Exists'
'Invalid Meta-Data Name'
|
|
|
addIndex
|
addIndex (
self,
name,
type,
)
Create a new index, of one of the following types
Types: FieldIndex , TextIndex , KeywordIndex .
Exceptions
|
|
'Index Exists'
'Invalid Index Name'
'Unknown Index Type'
|
|
|
catalogObject
|
catalogObject (
self,
object,
uid,
threshold=None,
)
Adds an object to the Catalog by iteratively applying it
all indexes.
object is the object to be cataloged
uid is the unique Catalog identifier for this object
|
|
clear
|
clear ( self )
clear catalog
|
|
delColumn
|
delColumn ( self, name )
deletes a row from the meta data schema
|
|
delIndex
|
delIndex ( self, name )
deletes an index
|
|
hasuid
|
hasuid ( self, uid )
return the rid if catalog contains an object with uid
|
|
instantiate
|
instantiate ( self, record )
|
|
recordify
|
recordify ( self, object )
turns an object into a record tuple
|
|
searchResults
|
searchResults (
self,
REQUEST=None,
used=None,
query_map={ type(regex.compile( '' ) ) : Query.Regex, type([] ) : orify, type( '' ) : Query.String, },
**kw,
)
|
|
uncatalogObject
|
uncatalogObject ( self, uid )
Uncatalog and object from the Catalog. and uid is a unique
Catalog identifier
Note, the uid must be the same as when the object was
catalogued, otherwise it will not get removed from the catalog
This method should not raise an exception if the uid cannot
be found in the catalog.
|
|
uniqueValuesFor
|
uniqueValuesFor ( self, name )
return unique values for FieldIndex name
|
|
updateBrains
|
updateBrains ( self )
|
|
useBrains
|
useBrains ( self, brains )
Sets up the Catalog to return an object (ala ZTables) that
is created on the fly from the tuple stored in the self.data
Btree.
|
|