[Zope-CVS] CVS: Products/AdaptableStorage/gateway_fs - FSClassificationSection.py:1.8 FSConnection.py:1.10

Shane Hathaway shane@zope.com
Thu, 9 Jan 2003 09:34:31 -0500


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

Modified Files:
	FSClassificationSection.py FSConnection.py 
Log Message:
- Added LoadEvent and StoreEvent, which currently serve only to
clarify the code.

- Added tests of conflict detection.

- Added NoStateFoundError.  Classification gateways now raise
NoStateFoundError at the right times so it's possible to detect
attempts to overwrite state with new objects

- Made it easier for a SQL gateway to use multiple tables by adding a
setupTables() method to SQLGatewayBase

- Made FieldSchema.addFieldType public.



=== Products/AdaptableStorage/gateway_fs/FSClassificationSection.py 1.7 => 1.8 ===
--- Products/AdaptableStorage/gateway_fs/FSClassificationSection.py:1.7	Fri Jan  3 17:04:17 2003
+++ Products/AdaptableStorage/gateway_fs/FSClassificationSection.py	Thu Jan  9 09:33:58 2003
@@ -42,21 +42,20 @@
     def load(self, event):
         c = self.fs_conn
         p = event.getKeychain()[-1]
+        classification = {'node_type': c.readNodeType(p)}
         text = c.readSection(p, 'classification', '')
-        classification = {}
         if text:
             lines = text.split('\n')
             for line in lines:
                 if '=' in line:
                     k, v = line.split('=', 1)
                     classification[k.strip()] = v.strip()
-        classification['node_type'] = c.readNodeType(p)
         classification['filename'] = self.getIdFrom(event)
         return classification, text.strip()
 
     def store(self, event, state):
-        classification = state
-        items = classification.items()
+        # state is a classification
+        items = state.items()
         items.sort()
         text = []
         for k, v in items:


=== Products/AdaptableStorage/gateway_fs/FSConnection.py 1.9 => 1.10 ===
--- Products/AdaptableStorage/gateway_fs/FSConnection.py:1.9	Tue Jan  7 14:09:37 2003
+++ Products/AdaptableStorage/gateway_fs/FSConnection.py	Thu Jan  9 09:33:58 2003
@@ -23,7 +23,7 @@
 
 from interfaces.public import IFSConnection
 from exceptions import FSWriteError
-from mapper_public import ITPCConnection
+from mapper_public import ITPCConnection, NoStateFoundError
 
 
 # Try to decipher this regular expression ;-)
@@ -120,6 +120,8 @@
 
     def readNodeType(self, subpath):
         path = self.expandPath(subpath)
+        if not os.path.exists(path):
+            raise NoStateFoundError(subpath)
         return os.path.isdir(path) and 'd' or 'f'
 
 
@@ -260,7 +262,7 @@
                 raise FSWriteError(
                     'Data or node type not specified for %s' % subpath)
             t = sections[NODE_TYPE_SECTION]
-            if t not in 'df':
+            if t not in ('d', 'f'):
                 raise FSWriteError(
                     'node type must be "d" or "f" at %s' % subpath)
             dir = os.path.dirname(subpath)