[Zope-CVS] CVS: Products/FileCacheManager - FileCacheManager.py:1.6 __init__.py:1.3

Jens Vagelpohl jens at dataflake.org
Fri Aug 13 08:06:27 EDT 2004


Update of /cvs-repository/Products/FileCacheManager
In directory cvs.zope.org:/tmp/cvs-serv12730

Modified Files:
	FileCacheManager.py __init__.py 
Log Message:
- clean up some comments
- add declarative security


=== Products/FileCacheManager/FileCacheManager.py 1.5 => 1.6 ===
--- Products/FileCacheManager/FileCacheManager.py:1.5	Fri Aug 13 07:33:18 2004
+++ Products/FileCacheManager/FileCacheManager.py	Fri Aug 13 08:06:27 2004
@@ -5,9 +5,11 @@
 
 import zLOG
 
-from os import path
 from thread import allocate_lock
 
+from AccessControl import ClassSecurityInfo
+from AccessControl.Permissions import view_management_screens
+from Globals import InitializeClass
 from BTrees import OOBTree
 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
 from ZPublisher.Iterators import filestream_iterator
@@ -46,12 +48,11 @@
         self._makeDirs()
 
     def ZCache_invalidate(self, ob):
-        """ Invalidates the cache entries that apply to ob.
-        code swiped from FSCacheManager.
-        XXX ADD LOCKS HERE"""
+        """ Invalidates cache entries that apply to ob, from FSCacheManager """
+        # XXX ADD LOCKS HERE
         fn = self._fileName(ob)
         try:
-            if path.exists(fn): # XXX race?
+            if os.path.exists(fn): # XXX race?
                 os.remove(fn)
         except IOError, msg:
              LOG('DiskCacheManger', ERROR, 'IOError removing file', error=msg)
@@ -73,10 +74,8 @@
 
     def ZCache_set(self, ob, data=None, view_name='', keywords=None,
                    mtime_func=None):
-        """ Sets a cache entry.
-        Code swiped from FSCacheManager.
-
-        XXX locks?"""
+        """ Sets a cache entry. Code swiped from FSCacheManager. """
+        # XXX locks?
         fnId = self._fileName(ob)
 
         if data is None:
@@ -110,7 +109,6 @@
                     os.unlink(fnId)
                     os.rename(tempname, fnId)
 
-
         except IOError, msg:
             LOG('DiskCacheManger', ERROR, 'IOError writing file', error=msg)
 
@@ -130,7 +128,7 @@
 
 class FileCacheManager(RAMCacheManager):
     """ A cache manager for caching data to filesystem """
-
+    security = ClassSecurityInfo()
     meta_type = 'File Cache Manager'
 
     
@@ -165,14 +163,14 @@
 
             return cache
 
-
+    security.declareProtected(view_management_screens, 'getDir')
     def getDir(self):
         """ Return the cache directory path """
         cache = self.ZCacheManager_getCache()
 
         return cache.getDir()
 
-
+    security.declareProtected('Change cache managers', 'setDir')
     def setDir(self, path):
         """ Set the cache directory path """
         cache = self.ZCacheManager_getCache()
@@ -182,6 +180,8 @@
             self._dir = path
         except ValueError:
             pass
+
+InitializeClass(FileCacheManager)
 
 
 manage_addFileCacheManagerForm = PageTemplateFile('www/addFCM', globals())


=== Products/FileCacheManager/__init__.py 1.2 => 1.3 ===
--- Products/FileCacheManager/__init__.py:1.2	Fri Aug 13 04:29:04 2004
+++ Products/FileCacheManager/__init__.py	Fri Aug 13 08:06:27 2004
@@ -4,6 +4,7 @@
 def initialize(context):
     context.registerClass(
         FileCacheManager.FileCacheManager,
+        permission = 'Add FileCacheManagers',
         constructors = (FileCacheManager.manage_addFileCacheManagerForm,
                         FileCacheManager.manage_addFileCacheManager),
         icon="www/cache.gif"



More information about the Zope-CVS mailing list