Package grassyknoll :: Package collection :: Module Collection :: Class Collection
[hide private]

Class Collection

source code


A bunch of items.

Items in a collection are uniquely identified by a id. Implementations are responsible for maintaining this constraint.

Items are added as instances of CollectionDocument and retrieved as instances of CollectionResult.

Implementations are free to interpret various methods however is reasonable. They may also choose not to implement methods if they are not applicable. The methods in this class all raise NotImplementedError.

Implementations may also provide query methods, named like fooQuery. These methods may take whatever keyword arguments desired. They should return the results of the query as a CollectionResultSet.

XXX: should we have an subclass attr describing what methods are provided?

Instance Methods [hide private]
CollectionIds
create(self, docs)
XXX this should prolly return None
source code
CollectionIds
delete(self, ids)
delete several CollectionDocuments by id
source code
CollectionIds
list(self)
Returns: the ids in the collection
source code
CollectionResultSet
retrieve(self, ids, fields=None)
retrive several CollectionResults by id
source code
 
__len__(self) source code
 
close(self)
free resources associated with this collection
source code
 
cleanUp(self)
remove the collection from disk.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Class Methods [hide private]

Inherited from lib.meta.FactoryMixin: factory

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

create(self, docs)

source code 
XXX this should prolly return None
Parameters:
Returns: CollectionIds
the created ids

delete(self, ids)

source code 

delete several CollectionDocuments by id

XXX this should prolly return None
Parameters:
  • ids (list of string) - the ids to delete
Returns: CollectionIds
the deleted ids

list(self)

source code 
Returns: CollectionIds
the ids in the collection

retrieve(self, ids, fields=None)

source code 
retrive several CollectionResults by id
Parameters:
  • ids (list of string) - the ids of the results
  • fields (set) - a sub-set of fields that should be returned. Defaults to None, meaning all available fields. XXX why a set? we use tuples everywhere...
Returns: CollectionResultSet
the results

cleanUp(self)

source code 
remove the collection from disk. Useful for testing