Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes
CMFTopic.tests.test_Topic.DummyCatalog Class Reference
Inheritance diagram for CMFTopic.tests.test_Topic.DummyCatalog:
Inheritance graph
[legend]
Collaboration diagram for CMFTopic.tests.test_Topic.DummyCatalog:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def searchResults

Static Public Attributes

 indexObject = _index
 reindexObject = _index

Private Member Functions

def _index

Private Attributes

 _objects
 _index_ids
 _indexes

Detailed Description

Definition at line 57 of file test_Topic.py.


Constructor & Destructor Documentation

def CMFTopic.tests.test_Topic.DummyCatalog.__init__ (   self,
  index_ids = () 
)

Definition at line 59 of file test_Topic.py.

00059 
00060     def __init__( self, index_ids=() ):
00061 
00062         self._objects = []
00063         self._index_ids = index_ids
00064         self._indexes = {}
00065 
00066         for index_id in index_ids:
00067             self._indexes[ index_id ] = {}


Member Function Documentation

def CMFTopic.tests.test_Topic.DummyCatalog._index (   self,
  obj,
  idxs = [] 
) [private]

Definition at line 68 of file test_Topic.py.

00068 
00069     def _index( self, obj, idxs=[] ):
00070 
00071         marker = object()
00072         self._objects.append( obj )
00073 
00074         rid = len( self._objects ) - 1
00075 
00076         for index_id in self._index_ids:
00077 
00078             value = getattr( obj, index_id, marker )
00079 
00080             if value is not marker:
00081                 for word in value.split():
00082                     bucket = self._indexes[ index_id ].setdefault( word, [] )
00083                     bucket.append( rid )

Here is the caller graph for this function:

def CMFTopic.tests.test_Topic.DummyCatalog.searchResults (   self,
  REQUEST = None,
  kw 
)

Definition at line 88 of file test_Topic.py.

00088 
00089     def searchResults( self, REQUEST=None, **kw ):
00090 
00091         limit = None
00092 
00093         criteria = kw.copy()
00094 
00095         if REQUEST is not None:
00096             for k, v in REQUEST:
00097                 criteria[ k ] = v
00098 
00099         results = set(range(len(self._objects)))
00100 
00101         for k, v in criteria.items():
00102 
00103             if k == 'sort_limit':
00104                 limit = v
00105 
00106             else:
00107                 results &= set(self._indexes[k].get(v, []))
00108 
00109         results = [ x for x in results ]
00110 
00111         if limit is not None:
00112             results = results[ :limit ]
00113 
00114         return [ FauxBrain( self._objects[ rid ] ) for rid in results ]
00115 

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 62 of file test_Topic.py.

Definition at line 63 of file test_Topic.py.

Definition at line 61 of file test_Topic.py.

Definition at line 84 of file test_Topic.py.

Definition at line 86 of file test_Topic.py.


The documentation for this class was generated from the following file: