Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes
AdvancedQuery.AdvancedQuery._CompositeQuery Class Reference
Inheritance diagram for AdvancedQuery.AdvancedQuery._CompositeQuery:
Inheritance graph
[legend]
Collaboration diagram for AdvancedQuery.AdvancedQuery._CompositeQuery:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def __str__
def addSubquery
def __and__
def __or__
def __invert__

Static Public Attributes

 addSubquery__roles__ = None

Private Member Functions

def _clone
def _classifySubqueries

Private Attributes

 _subqueries

Static Private Attributes

 _OP = None

Detailed Description

Definition at line 150 of file AdvancedQuery.py.


Constructor & Destructor Documentation

Definition at line 154 of file AdvancedQuery.py.

00154 
00155   def __init__(self, *queries):
00156     self._subqueries= []
00157     for q in queries: self.addSubquery(q)

Here is the caller graph for this function:


Member Function Documentation

def AdvancedQuery.AdvancedQuery._BaseQuery.__and__ (   self,
  other 
) [inherited]
self & other

Definition at line 35 of file AdvancedQuery.py.

00035 
00036   def __and__(self, other):
00037     '''self & other'''
00038     if isinstance(self,And): r = self._clone()
00039     else: r = And(self)
00040     r.addSubquery(other)
00041     return r

Here is the call graph for this function:

~ self

Definition at line 49 of file AdvancedQuery.py.

00049 
00050   def __invert__(self):
00051     '''~ self'''
00052     return Not(self)

def AdvancedQuery.AdvancedQuery._BaseQuery.__or__ (   self,
  other 
) [inherited]
self | other

Definition at line 42 of file AdvancedQuery.py.

00042 
00043   def __or__(self, other):
00044     '''self | other'''
00045     if isinstance(self,Or): r = self._clone()
00046     else: r = Or(self)
00047     r.addSubquery(other)
00048     return r

Here is the call graph for this function:

Reimplemented from AdvancedQuery.AdvancedQuery._BaseQuery.

Definition at line 158 of file AdvancedQuery.py.

00158 
00159   def __str__(self):
00160     return '(%s)' % (' %s ' % self._OP).join([str(q) for q in self._subqueries])

auxiliary method to classify subqueries into various categories:

'empty' -- empty subquery; leading to a degenerated evaluation

'index lookup' -- assumed to be fast and giving small results

'complex' -- some complex subquery of different type (subqueries of
  the same type are included)

'indexed' -- assumed to give rather large results

'notQ' -- expensive, large results expected

Definition at line 170 of file AdvancedQuery.py.

00170 
00171   def _classifySubqueries(self):
00172     '''auxiliary method to classify subqueries into various categories:
00173 
00174     'empty' -- empty subquery; leading to a degenerated evaluation
00175 
00176     'index lookup' -- assumed to be fast and giving small results
00177 
00178     'complex' -- some complex subquery of different type (subqueries of
00179       the same type are included)
00180 
00181     'indexed' -- assumed to give rather large results
00182 
00183     'notQ' -- expensive, large results expected
00184     '''
00185     sqs = self._subqueries[:]
00186     empty = []; lookup = []; complex = []; indexed = []; notQ = []
00187     while sqs:
00188       q= sqs.pop()
00189       if isinstance(q,_ElementaryQuery): lookup.append(q); continue
00190       if q.__class__ is self.__class__:
00191         # swallow
00192         sqs.extend(q._subqueries)
00193         continue
00194       if isinstance(q,_CompositeQuery):
00195         if not q._subqueries: empty.append(q); break # degenerate
00196         complex.append(q)
00197         continue
00198       if isinstance(q,Not): notQ.append(q); continue
00199       indexed.append(q); continue
00200     if empty: return {'empty':1} # this is by purpose -- to get remembered when we should derive another class from "_CompositeQuery"
00201     return {'empty':empty, 'lookup':lookup, 'complex':complex,
00202             'indexed':indexed, 'notQ':notQ,
00203             }
00204 
      

Here is the caller graph for this function:

ATT: not a true clone operation.

Reimplemented from AdvancedQuery.AdvancedQuery._BaseQuery.

Definition at line 167 of file AdvancedQuery.py.

00167 
00168   def _clone(self):
00169     return self.__class__(*self._subqueries)

Definition at line 162 of file AdvancedQuery.py.

00162 
00163   def addSubquery(self,query):
00164     assert isinstance(query,_BaseQuery)
00165     self._subqueries.append(query)
00166     return self


Member Data Documentation

Reimplemented in AdvancedQuery.AdvancedQuery.Or, and AdvancedQuery.AdvancedQuery.And.

Definition at line 152 of file AdvancedQuery.py.

Definition at line 155 of file AdvancedQuery.py.

Definition at line 161 of file AdvancedQuery.py.


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