[Zope-Checkins] CVS: Products/AdaptableStorage/gateway_fs - FSUserList.py:1.3

Shane Hathaway shane@zope.com
Tue, 7 Jan 2003 10:14:56 -0500


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

Modified Files:
	FSUserList.py 
Log Message:
Fixed bugs:

- NameError in SQLUserList, fixed.

- FSUserList left lines alone that it didn't recognize, which looked
odd when pickles were involved.  Now it removes unparseable lines when
writing.

- UserFolderSerializer wasn't adding all of the unmanaged persistent
objects to the event.


=== Products/AdaptableStorage/gateway_fs/FSUserList.py 1.2 => 1.3 ===
--- Products/AdaptableStorage/gateway_fs/FSUserList.py:1.2	Tue Jan  7 00:07:34 2003
+++ Products/AdaptableStorage/gateway_fs/FSUserList.py	Tue Jan  7 10:14:22 2003
@@ -16,7 +16,7 @@
 $Id$
 """
 
-from mapper_public import IGateway, RowSequenceSchema
+from mapper_public import IGateway, RowSequenceSchema, MappingError
 
 
 class FSUserList:
@@ -43,7 +43,7 @@
         res = []
         for line in text.split('\n'):
             L = line.strip()
-            if ':' in L:
+            if not L.startswith('#') and ':' in L:
                 id, password, rolelist, domainlist = L.split(':', 3)
                 roles = self._splitList(rolelist)
                 domains = self._splitList(domainlist)
@@ -60,15 +60,15 @@
         for item in items:
             if item.strip() != item:
                 raise MappingError(
-                    "Leading and trailing whitespace are not allowed in %s"
-                    % repr(item))
+                    "Leading and trailing whitespace are not allowed "
+                    "in roles and domains")
             item = item.strip()
             if not item:
-                raise MappingError("Empty role/domain not allowed")
+                raise MappingError("Empty role or domain not allowed")
             if ',' in item or ':' in item or '\n' in item:
                 raise MappingError(
-                    "Commas, colons, and newlines are not allowed in %s"
-                    % repr(item))
+                    "Commas, colons, and newlines are not allowed "
+                    "in roles and domains")
         return ','.join(items)
 
 
@@ -77,6 +77,8 @@
         for id, password, roles, domains in state:
             if ':' in id or '\n' in id:
                 raise MappingError('User IDs cannot have colons or newlines')
+            if id.startswith('#'):
+                raise MappingError('User IDs cannot start with #')
             if ':' in password or '\n' in password:
                 raise MappingError('Passwords cannot have colons or newlines')
             rolelist = self._joinList(roles)
@@ -92,12 +94,13 @@
         # Replace / remove users
         for line in text.split('\n'):
             L = line.strip()
-            if ':' in L:
-                name, stuff = L.split(':', 1)
-                replace = replace_lines.get(name, '')
-                if replace and replace != L:
-                    new_lines.append(replace)
-                    del replace_lines[name]
+            if not L.startswith('#'):
+                if ':' in L:
+                    name, stuff = L.split(':', 1)
+                    replace = replace_lines.get(name, '')
+                    if replace and replace != L:
+                        new_lines.append(replace)
+                        del replace_lines[name]
                 # else remove the line
             else:
                 new_lines.append(line)