Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes | Private Attributes | Static Private Attributes
ATContentTypes.tool.topic.ATTopicsTool Class Reference
Inheritance diagram for ATContentTypes.tool.topic.ATTopicsTool:
Inheritance graph
[legend]
Collaboration diagram for ATContentTypes.tool.topic.ATTopicsTool:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def getCriteriaForIndex
def addIndex
def addMetadata
def updateIndex
def updateMetadata
def removeIndex
def removeMetadata
def createInitialIndexes
def createInitialMetadata
def listCatalogFields
def listCatalogMetadata
def getAllPortalTypes
def getAllowedPortalTypes
def getEnabledIndexes
def getEnabledMetadata
def getIndexDisplay
def getMetadataDisplay
def getEnabledFields
def getFriendlyName
def getIndexes
def getAllMetadata
def getIndex
def getMetadata
def manage_saveTopicSetup
def manage_saveTopicSetupTypes

Public Attributes

 topic_indexes
 topic_metadata
 allowed_portal_types

Static Public Attributes

tuple security = ClassSecurityInfo()
list allowed_portal_types = []
 id = TOOLNAME
string meta_type = 'ATTopics Tool'
string title = 'ATTopics Tool'
 plone_tool = True

Private Attributes

 _p_changed

Static Private Attributes

tuple __implements__ = (IATCTTopicsTool,)

Detailed Description

This tool makes it possible to manage the indexes that are used
   inside topics and allows you to enter a friendly name instead of
   cryptic indexes.

Definition at line 25 of file topic.py.


Constructor & Destructor Documentation

Definition at line 43 of file topic.py.

00043 
00044     def __init__(self):
00045         self.topic_indexes = {}
00046         self.topic_metadata = {}
00047         self.allowed_portal_types = []


Member Function Documentation

def ATContentTypes.tool.topic.ATTopicsTool.addIndex (   self,
  index,
  friendlyName = '',
  description = '',
  enabled = False,
  criteria = None 
)
Add a new index along with descriptive information to the index
    registry 

Definition at line 66 of file topic.py.

00066 
00067     def addIndex(self, index, friendlyName='', description='', enabled=False, criteria=None):
00068         """ Add a new index along with descriptive information to the index
00069             registry """
00070         if criteria is None:
00071             criteria = self.getCriteriaForIndex(index)
00072         if self.topic_indexes.has_key(index):
00073             objIndex = self.topic_indexes[index]
00074             objIndex.friendlyName=friendlyName
00075             objIndex.description=description
00076             objIndex.enabled=enabled
00077             objIndex.criteria=tuple(criteria)
00078         else:
00079             objIndex = TopicIndex(index, friendlyName, description, enabled, criteria)
00080 
00081         self.topic_indexes[index] = objIndex
00082         self._p_changed = True

Here is the call graph for this function:

Here is the caller graph for this function:

def ATContentTypes.tool.topic.ATTopicsTool.addMetadata (   self,
  metadata,
  friendlyName = '',
  description = '',
  enabled = False 
)
Add a new metadata field along with descriptive information to the
    metadata registry 

Definition at line 84 of file topic.py.

00084 
00085     def addMetadata(self, metadata, friendlyName='', description='', enabled=False):
00086         """ Add a new metadata field along with descriptive information to the
00087             metadata registry """
00088         if self.topic_metadata.has_key(metadata):
00089             objMeta = self.topic_metadata[metadata]
00090             objMeta.friendlyName=friendlyName
00091             objMeta.description=description
00092             objMeta.enabled=enabled
00093         else:
00094             objMeta = TopicIndex(metadata, friendlyName, description, enabled)
00095 
00096         self.topic_metadata[metadata] = objMeta
00097         self._p_changed = True

Here is the caller graph for this function:

create indexes for all indexes in the catalog 

Definition at line 142 of file topic.py.

00142 
00143     def createInitialIndexes(self):
00144         """ create indexes for all indexes in the catalog """
00145         indexes = self.listCatalogFields()
00146         for i in indexes:
00147             if not self.topic_indexes.has_key(i):
00148                 enabled = False
00149                 self.addIndex(i, friendlyName='', enabled=enabled)
00150         return True

Here is the call graph for this function:

Here is the caller graph for this function:

create metadata for all indexes in the catalog 

Definition at line 152 of file topic.py.

00152 
00153     def createInitialMetadata(self):
00154         """ create metadata for all indexes in the catalog """
00155         metas = self.listCatalogMetadata()
00156         for i in metas:
00157             if not self.topic_metadata.has_key(i):
00158                 enabled = False
00159                 self.addMetadata(i, friendlyName='', enabled=enabled)
00160         return True

Here is the call graph for this function:

Here is the caller graph for this function:

def ATContentTypes.tool.topic.ATTopicsTool.getAllMetadata (   self,
  enabledOnly = False 
)
Returns the full list of available metadata fields, optionally
    filtering out those that are not marked enabled 

Definition at line 272 of file topic.py.

00272 
00273     def getAllMetadata(self, enabledOnly=False):
00274         """ Returns the full list of available metadata fields, optionally
00275             filtering out those that are not marked enabled """
00276         if enabledOnly:
00277             meta_dec = [(i.index.lower(), i.index) for i in self.getEnabledMetadata()]
00278         else:
00279             self.createInitialMetadata() # update in case of new catalogue metadata
00280             meta_dec = [(i.lower(), i) for i in self.topic_metadata.keys()]
00281 
00282         meta_dec.sort()
00283         metadata = [i[1] for i in meta_dec]
00284         return metadata

Here is the call graph for this function:

Here is the caller graph for this function:

def ATContentTypes.tool.topic.ATTopicsTool.getAllowedPortalTypes (   self,
  populate_for_end_usage = 1 
)
Return all portal_types as an (id,title) tuple that are allowed
    to search with 

Definition at line 187 of file topic.py.

00187 
00188     def getAllowedPortalTypes(self, populate_for_end_usage=1):
00189         """ Return all portal_types as an (id,title) tuple that are allowed
00190             to search with """
00191         all_types = self.getAllPortalTypes()
00192 
00193         if populate_for_end_usage==0:
00194             # return whatever is in self.allowed_portal_types and make it a (id, title) tuple
00195             return [t for t in all_types if t[0] in self.allowed_portal_types]
00196 
00197         if self.allowed_portal_types==[]:
00198             filtered_types = all_types
00199         else:
00200             filtered_types = [type for type in all_types if type[0] in self.allowed_portal_types]
00201 
00202         return filtered_types

Here is the call graph for this function:

returns a list of (id, title)-tuples for each type 

Definition at line 179 of file topic.py.

00179 
00180     def getAllPortalTypes(self):
00181         """ returns a list of (id, title)-tuples for each type """
00182         types_tool = getToolByName(self, 'portal_types')
00183         types = types_tool.listTypeInfo()
00184 
00185         all_types=[(t.id, t.title or t.id) for t in types]
00186         return all_types

Here is the call graph for this function:

Here is the caller graph for this function:

def ATContentTypes.tool.topic.ATTopicsTool.getCriteriaForIndex (   self,
  index,
  as_dict = False 
)
Returns the valid criteria for a given index 

Definition at line 48 of file topic.py.

00048 
00049     def getCriteriaForIndex(self, index, as_dict=False):
00050         """ Returns the valid criteria for a given index """
00051         catalog_tool = getToolByName(self, CatalogTool.id)
00052         try:
00053             indexObj = catalog_tool.Indexes[index]
00054         except KeyError:
00055             return ()
00056         criteria = tuple(_criterionRegistry.criteriaByIndex(indexObj.meta_type))
00057         search_criteria = _criterionRegistry.listSearchTypes()
00058         if as_dict:
00059             criteria = [{'name': a, 'description': _criterionRegistry[a].shortDesc}
00060                                 for a in criteria if a in search_criteria]
00061         else:
00062             criteria = [a for a in criteria if a in search_criteria]
00063         criteria.sort()
00064         return criteria

Here is the call graph for this function:

Here is the caller graph for this function:

Returns a list of tuples containing the index name, friendly name,
    and description for each enabled index. 

Definition at line 237 of file topic.py.

00237 
00238     def getEnabledFields(self):
00239         """ Returns a list of tuples containing the index name, friendly name,
00240             and description for each enabled index. """
00241         enabledIndexes = self.getEnabledIndexes()
00242         dec_fields = [(i.friendlyName.lower() or \
00243                        i.index.lower(), i.index, i.friendlyName or \
00244                        i.index, i.description) for i in enabledIndexes]
00245         dec_fields.sort()
00246         fields = [(a[1],a[2],a[3]) for a in dec_fields]
00247         return fields

Here is the call graph for this function:

Returns all TopicIndex objects for enabled indexes 

Definition at line 203 of file topic.py.

00203 
00204     def getEnabledIndexes(self):
00205         """ Returns all TopicIndex objects for enabled indexes """
00206         indexes = self.topic_indexes
00207         results = [i for i in indexes.values() if i.enabled]
00208         return results

Here is the caller graph for this function:

Returns all TopicIndex objects for enabled metadata 

Definition at line 209 of file topic.py.

00209 
00210     def getEnabledMetadata(self):
00211         """ Returns all TopicIndex objects for enabled metadata """
00212         meta = self.topic_metadata
00213         results = [i for i in meta.values() if i.enabled]
00214         return results

Here is the caller graph for this function:

Returns the friendly name for a given index name, or the given
    index if the firendlyname is empty or the index is not recognized

Definition at line 248 of file topic.py.

00248 
00249     def getFriendlyName(self, index):
00250         """ Returns the friendly name for a given index name, or the given
00251             index if the firendlyname is empty or the index is not recognized
00252         """
00253         if self.topic_indexes.has_key(index):
00254             return self.getIndex(index).friendlyName or index
00255         else:
00256             return index

Here is the call graph for this function:

Returns the TopicIndex object for a given index name 

Definition at line 285 of file topic.py.

00285 
00286     def getIndex(self, index):
00287         """ Returns the TopicIndex object for a given index name """
00288         if self.topic_indexes.has_key(index):
00289             return self.topic_indexes[index]
00290         else:
00291             raise AttributeError('Index ' + str(index) + ' not found')

Here is the caller graph for this function:

def ATContentTypes.tool.topic.ATTopicsTool.getIndexDisplay (   self,
  enabled = True 
)
Return DisplayList of Indexes and their friendly names 

Definition at line 215 of file topic.py.

00215 
00216     def getIndexDisplay(self, enabled=True):
00217         """ Return DisplayList of Indexes and their friendly names """
00218         if enabled:
00219             index_names = self.getIndexes(True)
00220         else:
00221             index_names = self.getIndexes()
00222         index_dict = self.topic_indexes
00223         indexes = [index_dict[i] for i in index_names]
00224         field_list=[(f.index, f.friendlyName or f.index) for f in indexes]
00225         return DisplayList(field_list)

Here is the call graph for this function:

def ATContentTypes.tool.topic.ATTopicsTool.getIndexes (   self,
  enabledOnly = False 
)
Returns the full list of available indexes, optionally filtering
    out those that are not marked enabled 

Definition at line 258 of file topic.py.

00258 
00259     def getIndexes(self, enabledOnly=False):
00260         """ Returns the full list of available indexes, optionally filtering
00261             out those that are not marked enabled """
00262         if enabledOnly:
00263             indexes_dec = [(i.index.lower(), i.index) for i in self.getEnabledIndexes()]
00264         else:
00265             self.createInitialIndexes() # update in case of new catalogue indexes
00266             indexes_dec = [(i.lower(), i) for i in self.topic_indexes.keys()]
00267 
00268         indexes_dec.sort()
00269         indexes = [i[1] for i in indexes_dec]
00270         return indexes

Here is the call graph for this function:

Here is the caller graph for this function:

Returns the TopicIndex object for a given metadata name 

Definition at line 292 of file topic.py.

00292 
00293     def getMetadata(self, metadata):
00294         """ Returns the TopicIndex object for a given metadata name """
00295         if self.topic_metadata.has_key(metadata):
00296             return self.topic_metadata[metadata]
00297         else:
00298             raise AttributeError('Metadata ' + str(metadata) + ' not found')

def ATContentTypes.tool.topic.ATTopicsTool.getMetadataDisplay (   self,
  enabled = True 
)
Return DisplayList of Metadata and their friendly names 

Definition at line 226 of file topic.py.

00226 
00227     def getMetadataDisplay(self, enabled=True):
00228         """ Return DisplayList of Metadata and their friendly names """
00229         if enabled:
00230             meta_names = self.getAllMetadata(True)
00231         else:
00232             meta_names = self.getAllMetadata()
00233         meta_dict = self.topic_metadata
00234         meta = [meta_dict[i] for i in meta_names]
00235         field_list=[(f.index, f.friendlyName or f.index) for f in meta]
00236         return DisplayList(field_list)

Here is the call graph for this function:

Return a list of fields from portal_catalog. 

Definition at line 162 of file topic.py.

00162 
00163     def listCatalogFields(self):
00164         """ Return a list of fields from portal_catalog. """
00165         pcatalog = getToolByName( self,  CatalogTool.id )
00166         available = pcatalog.indexes()
00167         val = [ field for field in available ]
00168         val.sort()
00169         return val

Here is the call graph for this function:

Here is the caller graph for this function:

Return a list of columns from portal_catalog. 

Definition at line 171 of file topic.py.

00171 
00172     def listCatalogMetadata(self):
00173         """ Return a list of columns from portal_catalog. """
00174         pcatalog = getToolByName( self,  CatalogTool.id )
00175         available = pcatalog.schema()
00176         val = [ field for field in available ]
00177         val.sort()
00178         return val

Here is the call graph for this function:

Here is the caller graph for this function:

Set indexes and metadata from form 

Definition at line 300 of file topic.py.

00300 
00301     def manage_saveTopicSetup(self, REQUEST=None):
00302         """ Set indexes and metadata from form """
00303         if REQUEST==None:
00304             return  'Nothing saved.'
00305 
00306         data = REQUEST.get('index', [])
00307         for index in data:
00308             enabled = index.has_key('enabled')
00309             criteria = index.get('criteria', ())
00310             self.updateIndex(index['index'], index['friendlyName'], index['description'], enabled, criteria)
00311 
00312         meta = REQUEST.get('metadata', [])
00313         for metadata in meta:
00314             enabled = metadata.has_key('enabled')
00315             self.updateMetadata(metadata['index'], metadata['friendlyName'], metadata['description'], enabled)
00316         return True

Here is the call graph for this function:

Set portal types from form 

Definition at line 318 of file topic.py.

00318 
00319     def manage_saveTopicSetupTypes(self, REQUEST=None):
00320         """ Set portal types from form """
00321         if REQUEST==None:
00322             return  'Nothing saved.'
00323 
00324         self.allowed_portal_types = REQUEST.get('allowed_types', [])
00325         return True
00326 
00327 InitializeClass(ATTopicsTool)
00328 
Removes an existing index from the registry 

Definition at line 128 of file topic.py.

00128 
00129     def removeIndex(self, index):
00130         """ Removes an existing index from the registry """
00131         if self.topic_indexes.has_key(index):
00132             del self.topic_indexes[index]
00133             self._p_changed = True

Removes an existing metadata field from the registry 

Definition at line 135 of file topic.py.

00135 
00136     def removeMetadata(self, metadata):
00137         """ Removes an existing metadata field from the registry """
00138         if self.topic_metadata.has_key(metadata):
00139             del self.topic_metadata[metadata]
00140             self._p_changed = True

def ATContentTypes.tool.topic.ATTopicsTool.updateIndex (   self,
  index,
  friendlyName = None,
  description = None,
  enabled = None,
  criteria = None 
)
Updates an existing index in the registry, unrecognized values are
    added 

Definition at line 99 of file topic.py.

00099 
00100     def updateIndex(self, index, friendlyName=None, description=None, enabled=None, criteria=None):
00101         """ Updates an existing index in the registry, unrecognized values are
00102             added """
00103         indexes = self.topic_indexes
00104         if friendlyName == None:
00105             friendlyName = indexes[index].friendlyName
00106         if description == None:
00107             description = indexes[index].description
00108         if enabled == None:
00109             enabled = indexes[index].enabled
00110         if criteria == None:
00111             criteria = indexes[index].criteria
00112 
00113         self.addIndex(index, friendlyName, description, enabled, criteria)

Here is the call graph for this function:

Here is the caller graph for this function:

def ATContentTypes.tool.topic.ATTopicsTool.updateMetadata (   self,
  metadata,
  friendlyName = None,
  description = None,
  enabled = None 
)
Updates an existing metadata field in the registry, unrecognized values are
    added 

Definition at line 115 of file topic.py.

00115 
00116     def updateMetadata(self, metadata, friendlyName=None, description=None, enabled=None):
00117         """ Updates an existing metadata field in the registry, unrecognized values are
00118             added """
00119         meta = self.topic_metadata
00120         if friendlyName == None:
00121             friendlyName = meta[metadata].friendlyName
00122         if description == None:
00123             description = meta[metadata].description
00124         if enabled == None:
00125             enabled = meta[metadata].enabled
00126         self.addMetadata(metadata, friendlyName, description, enabled)

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

tuple ATContentTypes.tool.topic.ATTopicsTool.__implements__ = (IATCTTopicsTool,) [static, private]

Definition at line 30 of file topic.py.

Definition at line 81 of file topic.py.

Definition at line 36 of file topic.py.

Definition at line 46 of file topic.py.

Definition at line 38 of file topic.py.

string ATContentTypes.tool.topic.ATTopicsTool.meta_type = 'ATTopics Tool' [static]

Definition at line 39 of file topic.py.

Definition at line 41 of file topic.py.

tuple ATContentTypes.tool.topic.ATTopicsTool.security = ClassSecurityInfo() [static]

Definition at line 32 of file topic.py.

string ATContentTypes.tool.topic.ATTopicsTool.title = 'ATTopics Tool' [static]

Definition at line 40 of file topic.py.

Definition at line 44 of file topic.py.

Definition at line 45 of file topic.py.


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