[Zope-Checkins] CVS: Zope/lib/python/Products/ZCatalog - ZCatalog.py:1.120

Casey Duncan casey@zope.com
Thu, 15 Aug 2002 09:10:17 -0400


Update of /cvs-repository/Zope/lib/python/Products/ZCatalog
In directory cvs.zope.org:/tmp/cvs-serv7779

Modified Files:
	ZCatalog.py 
Log Message:
Small refactor of new getIndexObjects method. Tightened security (since wrapped indexes are more open to untrusted code) and generalized the other assertions for ZCat.


=== Zope/lib/python/Products/ZCatalog/ZCatalog.py 1.119 => 1.120 ===
--- Zope/lib/python/Products/ZCatalog/ZCatalog.py:1.119	Thu Aug 15 08:44:51 2002
+++ Zope/lib/python/Products/ZCatalog/ZCatalog.py	Thu Aug 15 09:10:16 2002
@@ -27,6 +27,8 @@
 from Catalog import Catalog, CatalogError
 from AccessControl import getSecurityManager
 from AccessControl.DTML import RestrictedDTML
+from AccessControl.Permissions import \
+    manage_zcatalog_entries, manage_zcatalog_indexes, search_zcatalog
 from zLOG import LOG, ERROR
 from ZCatalogIndexes import ZCatalogIndexes
 from Products.PluginIndexes.common.PluggableIndex \
@@ -113,7 +115,7 @@
 
     __ac_permissions__=(
 
-        ('Manage ZCatalog Entries',
+        (manage_zcatalog_entries,
          ['manage_catalogObject', 'manage_uncatalogObject',
           'catalog_object', 'uncatalog_object', 'refreshCatalog',
 
@@ -131,12 +133,16 @@
           ],
          ['Manager']),
 
-        ('Search ZCatalog',
+        (search_zcatalog,
          ['searchResults', '__call__', 'uniqueValuesFor',
-          'getpath', 'schema', 'indexes', 'index_objects', 'getIndexObjects'
+          'getpath', 'schema', 'indexes', 'index_objects', 
           'all_meta_types', 'valid_roles', 'resolve_url',
           'getobject'],
          ['Anonymous', 'Manager']),
+         
+        (manage_zcatalog_indexes, 
+         ['getIndexObjects'], 
+         ['Manager']),
         )
 
 
@@ -440,7 +446,7 @@
                 '/manage_catalogIndexes?manage_tabs_message=Index%20Cleared')
 
 
-    def reindexIndex(self,name,REQUEST):
+    def reindexIndex(self, name, REQUEST):
         paths = self._catalog.uids.keys()
 
         for p in paths:
@@ -568,8 +574,8 @@
 
     def getIndexObjects(self):
         # Return a list of wrapped(!) indexes
-        catalog = self._catalog
-        return [index.__of__(catalog) for index in catalog.indexes.values()]
+        getIndex = self._catalog.getIndex
+        return [getIndex(name) for name in self.indexes()]
 
     def _searchable_arguments(self):
         r = {}