Back to index

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

List of all members.

Public Member Functions

def __init__
def searchResults
def unrestrictedSearchResults
def catalog_object
def indexObject
def unindexObject
def reindexObject

Static Public Attributes

string id = 'portal_catalog'
string meta_type = 'CMF Catalog'
tuple security = ClassSecurityInfo()
tuple manage_options
tuple manage_overview = DTMLFile( 'explainCatalogTool', _dtmldir )
tuple manage_catalogFind = DTMLFile( 'catalogFind', _dtmldir )

Private Member Functions

def _listAllowedRolesAndUsers
def _convertQuery
def __url

Static Private Attributes

tuple __implements__
 __call__ = searchResults

Detailed Description

This is a ZCatalog that filters catalog queries.

Definition at line 113 of file CatalogTool.py.


Constructor & Destructor Documentation

Definition at line 133 of file CatalogTool.py.

00133 
00134     def __init__(self):
00135         ZCatalog.__init__(self, self.getId())


Member Function Documentation

def CMFCore.CatalogTool.CatalogTool.__url (   self,
  ob 
) [private]

Definition at line 244 of file CatalogTool.py.

00244 
00245     def __url(self, ob):
00246         return '/'.join( ob.getPhysicalPath() )

Here is the caller graph for this function:

def CMFCore.CatalogTool.CatalogTool._convertQuery (   self,
  kw 
) [private]

Definition at line 159 of file CatalogTool.py.

00159 
00160     def _convertQuery(self, kw):
00161         # Convert query to modern syntax
00162         for k in 'effective', 'expires':
00163             kusage = k+'_usage'
00164             if not kw.has_key(kusage):
00165                 continue
00166             usage = kw[kusage]
00167             if not usage.startswith('range:'):
00168                 raise ValueError("Incorrect usage %s" % `usage`)
00169             kw[k] = {'query': kw[k], 'range': usage[6:]}
00170             del kw[kusage]

Here is the caller graph for this function:

def CMFCore.CatalogTool.CatalogTool._listAllowedRolesAndUsers (   self,
  user 
) [private]

Definition at line 146 of file CatalogTool.py.

00146 
00147     def _listAllowedRolesAndUsers(self, user):
00148         effective_roles = user.getRoles()
00149         sm = getSecurityManager()
00150         if sm.calledByExecutable():
00151             eo = sm._context.stack[-1]
00152             proxy_roles = getattr(eo, '_proxy_roles', None)
00153             if proxy_roles is not None:
00154                 effective_roles = proxy_roles
00155         result = list( effective_roles )
00156         result.append( 'Anonymous' )
00157         result.append( 'user:%s' % user.getId() )
00158         return result

Here is the caller graph for this function:

def CMFCore.CatalogTool.CatalogTool.catalog_object (   self,
  obj,
  uid = None,
  idxs = None,
  update_metadata = 1,
  pghandler = None 
)

Definition at line 250 of file CatalogTool.py.

00250 
00251                        pghandler=None):
00252         # Wraps the object with workflow and accessibility
00253         # information just before cataloging.
00254         # XXX: this method violates the rules for tools/utilities:
00255         # it depends on a non-utility tool
00256         wftool = getToolByName(self, 'portal_workflow', None)
00257         if wftool is not None:
00258             vars = wftool.getCatalogVariablesFor(obj)
00259         else:
00260             vars = {}
00261         w = IndexableObjectWrapper(vars, obj)
00262         ZCatalog.catalog_object(self, w, uid, idxs, update_metadata,
00263                                 pghandler)

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFCore.CatalogTool.CatalogTool.indexObject (   self,
  object 
)
Add to catalog.

Definition at line 265 of file CatalogTool.py.

00265 
00266     def indexObject(self, object):
00267         """Add to catalog.
00268         """
00269         url = self.__url(object)
00270         self.catalog_object(object, url)

Here is the call graph for this function:

def CMFCore.CatalogTool.CatalogTool.reindexObject (   self,
  object,
  idxs = [],
  update_metadata = 1,
  uid = None 
)
Update catalog after object data has changed.

The optional idxs argument is a list of specific indexes
to update (all of them by default).

The update_metadata flag controls whether the object's
metadata record is updated as well.

If a non-None uid is passed, it will be used as the catalog uid
for the object instead of its physical path.

Definition at line 279 of file CatalogTool.py.

00279 
00280     def reindexObject(self, object, idxs=[], update_metadata=1, uid=None):
00281         """Update catalog after object data has changed.
00282 
00283         The optional idxs argument is a list of specific indexes
00284         to update (all of them by default).
00285 
00286         The update_metadata flag controls whether the object's
00287         metadata record is updated as well.
00288 
00289         If a non-None uid is passed, it will be used as the catalog uid
00290         for the object instead of its physical path.
00291         """
00292         if uid is None:
00293             uid = self.__url(object)
00294         if idxs != []:
00295             # Filter out invalid indexes.
00296             valid_indexes = self._catalog.indexes.keys()
00297             idxs = [i for i in idxs if i in valid_indexes]
00298         self.catalog_object(object, uid, idxs, update_metadata)
00299 
00300 InitializeClass(CatalogTool)

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFCore.CatalogTool.CatalogTool.searchResults (   self,
  REQUEST = None,
  kw 
)
    Calls ZCatalog.searchResults with extra arguments that
    limit the results to what the user is allowed to see.

Definition at line 172 of file CatalogTool.py.

00172 
00173     def searchResults(self, REQUEST=None, **kw):
00174         """
00175             Calls ZCatalog.searchResults with extra arguments that
00176             limit the results to what the user is allowed to see.
00177         """
00178         user = _getAuthenticatedUser(self)
00179         kw[ 'allowedRolesAndUsers' ] = self._listAllowedRolesAndUsers( user )
00180 
00181         if not _checkPermission( AccessInactivePortalContent, self ):
00182             now = DateTime()
00183 
00184             self._convertQuery(kw)
00185 
00186             # Intersect query restrictions with those implicit to the tool
00187             for k in 'effective', 'expires':
00188                 if kw.has_key(k):
00189                     range = kw[k]['range'] or ''
00190                     query = kw[k]['query']
00191                     if not isinstance(query, (tuple, list)):
00192                         query = (query,)
00193                 else:
00194                     range = ''
00195                     query = None
00196                 if range.find('min') > -1:
00197                     lo = min(query)
00198                 else:
00199                     lo = None
00200                 if range.find('max') > -1:
00201                     hi = max(query)
00202                 else:
00203                     hi = None
00204                 if k == 'effective':
00205                     if hi is None or hi > now:
00206                         hi = now
00207                     if lo is not None and hi < lo:
00208                         return ()
00209                 else: # 'expires':
00210                     if lo is None or lo < now:
00211                         lo = now
00212                     if hi is not None and hi < lo:
00213                         return ()
00214                 # Rebuild a query
00215                 if lo is None:
00216                     query = hi
00217                     range = 'max'
00218                 elif hi is None:
00219                     query = lo
00220                     range = 'min'
00221                 else:
00222                     query = (lo, hi)
00223                     range = 'min:max'
00224                 kw[k] = {'query': query, 'range': range}
00225 
00226         return ZCatalog.searchResults(self, REQUEST, **kw)

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFCore.CatalogTool.CatalogTool.unindexObject (   self,
  object 
)
Remove from catalog.

Definition at line 272 of file CatalogTool.py.

00272 
00273     def unindexObject(self, object):
00274         """Remove from catalog.
00275         """
00276         url = self.__url(object)
00277         self.uncatalog_object(url)

Here is the call graph for this function:

def CMFCore.CatalogTool.CatalogTool.unrestrictedSearchResults (   self,
  REQUEST = None,
  kw 
)
Calls ZCatalog.searchResults directly without restrictions.

This method returns every also not yet effective and already expired
objects regardless of the roles the caller has.

CAUTION: Care must be taken not to open security holes by
exposing the results of this method to non authorized callers!

If you're in doubt if you should use this method or
'searchResults' use the latter.

Definition at line 230 of file CatalogTool.py.

00230 
00231     def unrestrictedSearchResults(self, REQUEST=None, **kw):
00232         """Calls ZCatalog.searchResults directly without restrictions.
00233 
00234         This method returns every also not yet effective and already expired
00235         objects regardless of the roles the caller has.
00236 
00237         CAUTION: Care must be taken not to open security holes by
00238         exposing the results of this method to non authorized callers!
00239 
00240         If you're in doubt if you should use this method or
00241         'searchResults' use the latter.
00242         """
00243         return ZCatalog.searchResults(self, REQUEST, **kw)


Member Data Documentation

Definition at line 227 of file CatalogTool.py.

Initial value:
(z2ICatalogTool, ZCatalog.__implements__,
                      ActionProviderBase.__implements__)

Definition at line 119 of file CatalogTool.py.

string CMFCore.CatalogTool.CatalogTool.id = 'portal_catalog' [static]

Definition at line 122 of file CatalogTool.py.

tuple CMFCore.CatalogTool.CatalogTool.manage_catalogFind = DTMLFile( 'catalogFind', _dtmldir ) [static]

Definition at line 247 of file CatalogTool.py.

Initial value:
( ZCatalog.manage_options +
                      ActionProviderBase.manage_options +
                      ({ 'label' : 'Overview', 'action' : 'manage_overview' }
                     ,
                     ))

Definition at line 127 of file CatalogTool.py.

tuple CMFCore.CatalogTool.CatalogTool.manage_overview = DTMLFile( 'explainCatalogTool', _dtmldir ) [static]

Definition at line 140 of file CatalogTool.py.

string CMFCore.CatalogTool.CatalogTool.meta_type = 'CMF Catalog' [static]

Definition at line 123 of file CatalogTool.py.

tuple CMFCore.CatalogTool.CatalogTool.security = ClassSecurityInfo() [static]

Definition at line 125 of file CatalogTool.py.


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