Back to index

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

List of all members.

Public Member Functions

def listCriteria
def listCriteriaTypes
def listAvailableFields
def listSubtopics
def edit
def buildQuery
def queryCatalog
def synContentValues
def addCriterion
 Criteria adding/editing/deleting.
def deleteCriterion
def getCriterion
def addSubtopic

Public Attributes

 title
 description

Static Public Attributes

tuple security = ClassSecurityInfo()
 acquireCriteria = True

Private Member Functions

def _criteria_metatype_ids

Static Private Attributes

list _criteriaTypes = []

Detailed Description

Topics are 'canned queries'.

o Each topic holds a set of zero or more Criteria objects specifying
  the query.

Definition at line 49 of file Topic.py.


Member Function Documentation

Definition at line 211 of file Topic.py.

00211 
00212     def _criteria_metatype_ids(self):
00213 
00214         result = []
00215 
00216         for mt in self._criteriaTypes:
00217             result.append( mt.meta_type )
00218 
00219         return tuple( result )
00220 
00221 InitializeClass(Topic)

Here is the caller graph for this function:

def CMFTopic.Topic.Topic.addCriterion (   self,
  field,
  criterion_type 
)

Criteria adding/editing/deleting.

Add a new search criterion.

Definition at line 163 of file Topic.py.

00163 
00164     def addCriterion(self, field, criterion_type):
00165         """ Add a new search criterion.
00166         """
00167         crit = None
00168         newid = 'crit__%s' % field
00169 
00170         for ct in self._criteriaTypes:
00171 
00172             if criterion_type == ct.meta_type:
00173                 crit = ct( newid, field )
00174 
00175         if crit is None:
00176             # No criteria type matched passed in value
00177             raise NameError, 'Unknown Criterion Type: %s' % criterion_type
00178 
00179         self._setObject( newid, crit )

Here is the call graph for this function:

def CMFTopic.Topic.Topic.addSubtopic (   self,
  id 
)
Add a new subtopic.

Definition at line 200 of file Topic.py.

00200 
00201     def addSubtopic(self, id):
00202         """ Add a new subtopic.
00203         """
00204         ti = self.getTypeInfo()
00205         ti.constructInstance(self, id)
00206         return self._getOb( id )

Here is the call graph for this function:

Construct a catalog query using our criterion objects.

Definition at line 116 of file Topic.py.

00116 
00117     def buildQuery(self):
00118         """ Construct a catalog query using our criterion objects.
00119         """
00120         result = {}
00121 
00122         if self.acquireCriteria:
00123 
00124             try:
00125                 # Tracker 290 asks to allow combinations, like this:
00126                 # parent = aq_parent( self )
00127                 parent = aq_parent( aq_inner( self ) )
00128                 result.update( parent.buildQuery() )
00129 
00130             except: # oh well, can't find parent, or it isn't a Topic.
00131                 pass
00132 
00133         for criterion in self.listCriteria():
00134 
00135             for key, value in criterion.getCriteriaItems():
00136                 result[ key ] = value
00137 
00138         return result

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFTopic.Topic.Topic.deleteCriterion (   self,
  criterion_id 
)
Delete selected criterion.

Definition at line 181 of file Topic.py.

00181 
00182     def deleteCriterion(self, criterion_id):
00183         """ Delete selected criterion.
00184         """
00185         if type( criterion_id ) is type( '' ):
00186             self._delObject( criterion_id )
00187         elif type( criterion_id ) in ( type( () ), type( [] ) ):
00188             for cid in criterion_id:
00189                 self._delObject( cid )

Here is the call graph for this function:

def CMFTopic.Topic.Topic.edit (   self,
  acquireCriteria,
  title = None,
  description = None 
)
Set the flag which indicates whether to acquire criteria.

o If set, reuse creiteria from parent topics;

o Also update metadata about the Topic.

Definition at line 101 of file Topic.py.

00101 
00102     def edit(self, acquireCriteria, title=None, description=None):
00103         """ Set the flag which indicates whether to acquire criteria.
00104 
00105         o If set, reuse creiteria from parent topics;
00106 
00107         o Also update metadata about the Topic.
00108         """
00109         self.acquireCriteria = bool(acquireCriteria)
00110         if title is not None:
00111             self.title = title
00112         self.description = description
00113 
00114         self.reindexObject()

Here is the caller graph for this function:

def CMFTopic.Topic.Topic.getCriterion (   self,
  criterion_id 
)
Get the criterion object.

Definition at line 191 of file Topic.py.

00191 
00192     def getCriterion(self, criterion_id):
00193         """ Get the criterion object.
00194         """
00195         try:
00196             return self._getOb( 'crit__%s' % criterion_id )
00197         except AttributeError:
00198             return self._getOb( criterion_id )

Here is the call graph for this function:

Return a list of available fields for new criteria.

Definition at line 83 of file Topic.py.

00083 
00084     def listAvailableFields(self):
00085         """ Return a list of available fields for new criteria.
00086         """
00087         portal_catalog = getToolByName( self, 'portal_catalog' )
00088         currentfields = map( lambda x: x.Field(), self.listCriteria() )
00089         availfields = filter(
00090             lambda field, cf=currentfields: field not in cf,
00091             portal_catalog.indexes()
00092             )
00093         return availfields

Here is the call graph for this function:

Return a list of our criteria objects.

Definition at line 66 of file Topic.py.

00066 
00067     def listCriteria(self):
00068         """ Return a list of our criteria objects.
00069         """
00070         return self.objectValues( self._criteria_metatype_ids() )

Here is the call graph for this function:

Here is the caller graph for this function:

List the available criteria types.

Definition at line 72 of file Topic.py.

00072 
00073     def listCriteriaTypes(self):
00074         """ List the available criteria types.
00075         """
00076         out = []
00077 
00078         for ct in self._criteriaTypes:
00079             out.append( { 'name': ct.meta_type } )
00080 
00081         return out

Return a list of our subtopics.

Definition at line 95 of file Topic.py.

00095 
00096     def listSubtopics(self):
00097         """ Return a list of our subtopics.
00098         """
00099         return self.objectValues( self.meta_type )

Here is the call graph for this function:

def CMFTopic.Topic.Topic.queryCatalog (   self,
  REQUEST = None,
  kw 
)
Invoke the catalog using our criteria.

o Built-in criteria update any criteria passed in 'kw'.

Definition at line 140 of file Topic.py.

00140 
00141     def queryCatalog(self, REQUEST=None, **kw):
00142         """ Invoke the catalog using our criteria.
00143 
00144         o Built-in criteria update any criteria passed in 'kw'.
00145         """
00146         kw.update( self.buildQuery() )
00147         portal_catalog = getToolByName( self, 'portal_catalog' )
00148         return portal_catalog.searchResults(REQUEST, **kw)

Here is the call graph for this function:

Here is the caller graph for this function:

Return a limited subset of the brains for our query.

o Return no more brain objects than the limit set by the
  syndication tool.

Definition at line 150 of file Topic.py.

00150 
00151     def synContentValues(self):
00152         """ Return a limited subset of the brains for our query.
00153 
00154         o Return no more brain objects than the limit set by the
00155           syndication tool.
00156         """
00157         syn_tool = getUtility(ISyndicationTool)
00158         limit = syn_tool.getMaxItems( self )
00159         brains = self.queryCatalog( sort_limit=limit )[ :limit ]
00160         return [ brain.getObject() for brain in brains ]

Here is the call graph for this function:


Member Data Documentation

list CMFTopic.Topic.Topic._criteriaTypes = [] [static, private]

Definition at line 63 of file Topic.py.

Definition at line 62 of file Topic.py.

Definition at line 111 of file Topic.py.

tuple CMFTopic.Topic.Topic.security = ClassSecurityInfo() [static]

Definition at line 59 of file Topic.py.

Definition at line 110 of file Topic.py.


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