[Zope-CVS] CVS: Products/AdaptableStorage/gateway_fs - FSConnection.py:1.5

Shane Hathaway shane@zope.com
Tue, 31 Dec 2002 16:09:35 -0500


Update of /cvs-repository/Products/AdaptableStorage/gateway_fs
In directory cvs.zope.org:/tmp/cvs-serv13064/gateway_fs

Modified Files:
	FSConnection.py 
Log Message:
- Added ITPCConnection.  It doesn't really belong in the serial
package, but there's no other good place for it right now.

- FSConnection now allows a hidden filename prefix other than
".", such as "_", taking advantage of the fact that the Zope 2 security
model disallows leading underscores.

- Added some more docs.


=== Products/AdaptableStorage/gateway_fs/FSConnection.py 1.4 => 1.5 ===
--- Products/AdaptableStorage/gateway_fs/FSConnection.py:1.4	Mon Dec 23 23:29:31 2002
+++ Products/AdaptableStorage/gateway_fs/FSConnection.py	Tue Dec 31 16:09:04 2002
@@ -23,6 +23,7 @@
 
 from interfaces.public import IFSConnection
 from exceptions import FSWriteError
+from serial_public import ITPCConnection
 
 
 # Try to decipher this one ;-)
@@ -51,12 +52,13 @@
     square-bracket section headers and encodes sections by doubling
     left-square brackets.
     """
-    __implements__ = IFSConnection
+    __implements__ = IFSConnection, ITPCConnection
 
     basepath = ''
 
-    def __init__(self, basepath):
+    def __init__(self, basepath, hidden_filename_prefix='.'):
         self.basepath = basepath
+        self.hidden_filename_prefix = hidden_filename_prefix
         self._final = 0
         # _pending holds the data to be written.
         # _pending: { subpath string -> { section_name -> data } }
@@ -144,8 +146,9 @@
         # Read either the directory listing or the file contents.
         if isdir:
             names = []
+            prefix = self.hidden_filename_prefix
             for name in os.listdir(path):
-                if not name.startswith('.'):
+                if not name.startswith(self.hidden_filename_prefix):
                     names.append(name)
             # Return a sequence instead of a string.
             return names
@@ -159,10 +162,12 @@
 
     def getPropertiesPath(self, path):
         if os.path.isdir(path):
-            props_fn = os.path.join(path, '.properties')
+            props_fn = os.path.join(path, self.hidden_filename_prefix +
+                                    'properties')
         else:
             dirname, filename = os.path.split(path)
-            props_fn = os.path.join(dirname, '.%s.properties' % filename)
+            props_fn = os.path.join(dirname, self.hidden_filename_prefix +
+                                    ('%s.properties' % filename))
         return props_fn
 
 
@@ -241,8 +246,9 @@
         for name in names:
             linked[name] = 1
         existing = os.listdir(path)
+        prefix = self.hidden_filename_prefix
         for fn in existing:
-            if not fn.startswith('.') and not linked.get(fn):
+            if not fn.startswith(prefix) and not linked.get(fn):
                 item_fn = os.path.join(path, fn)
                 if os.path.isdir(item_fn):
                     rmtree(item_fn)