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

Shane Hathaway shane@zope.com
Wed, 5 Feb 2003 13:50:33 -0500


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

Modified Files:
	FSConnection.py 
Log Message:
- Added a 'hidden_filenames' option to FSConnection.  hidden_filenames
is a regular expression that determines whether a filename should be
visible or not.  By default, it makes all items that start with an
underscore invisible, since Zope won't be able to access them anyway.

- Changed the name of the 'hidden_filename_prefix' option
to 'metadata_prefix'.


=== Products/AdaptableStorage/gateway_fs/FSConnection.py 1.12 => 1.13 ===
--- Products/AdaptableStorage/gateway_fs/FSConnection.py:1.12	Wed Feb  5 10:08:01 2003
+++ Products/AdaptableStorage/gateway_fs/FSConnection.py	Wed Feb  5 13:49:59 2003
@@ -53,9 +53,10 @@
 
     basepath = ''
 
-    def __init__(self, basepath, hidden_filename_prefix='.'):
+    def __init__(self, basepath, metadata_prefix='.', hidden_filenames='_'):
         self.basepath = basepath
-        self.hidden_filename_prefix = hidden_filename_prefix
+        self.metadata_prefix = metadata_prefix
+        self.hidden_re = re.compile(hidden_filenames)
         self._final = 0
         # _pending holds the data to be written.
         # _pending: { subpath string -> { section_name -> data } }
@@ -81,9 +82,11 @@
         except OSError:
             if ignore_error:
                 return (filenames, obj_names, trans)
-        hidden_filename_prefix = self.hidden_filename_prefix
+        metadata_prefix = self.metadata_prefix
         for fn in fns:
-            if fn.startswith(hidden_filename_prefix):
+            if (not fn
+                or fn.startswith(metadata_prefix)
+                or self.hidden_re.match(fn) is not None):
                 continue
             filenames.append(fn)
 
@@ -220,11 +223,11 @@
 
     def getPropertiesPath(self, path):
         if os.path.isdir(path):
-            props_fn = os.path.join(path, self.hidden_filename_prefix +
+            props_fn = os.path.join(path, self.metadata_prefix +
                                     'properties')
         else:
             dirname, filename = os.path.split(path)
-            props_fn = os.path.join(dirname, self.hidden_filename_prefix +
+            props_fn = os.path.join(dirname, self.metadata_prefix +
                                     ('%s.properties' % filename))
         return props_fn
 
@@ -412,6 +415,12 @@
                     raise FSWriteError(
                         'Data for a directory must be a list or tuple at %s'
                         % subpath)
+                for item in items:
+                    if (not item
+                        or item.startswith(self.metadata_prefix)
+                        or self.hidden_re.match(item) is not None):
+                        raise FSWriteError(
+                            'Not a legal object name: %s' % repr(item))
             else:
                 raise FSWriteError(
                     'Node type must be "d" or "f" at %s' % subpath)