[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/Security/Grants - FSSync.py:1.2 configure.zcml:1.3.8.1

Jim Fulton jim@zope.com
Fri, 11 Oct 2002 02:28:07 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/Security/Grants
In directory cvs.zope.org:/tmp/cvs-serv1649/lib/python/Zope/App/Security/Grants

Modified Files:
      Tag: FileSystemSync-branch
	configure.zcml 
Added Files:
	FSSync.py 
Log Message:
adding (back) changed to branch

=== Zope3/lib/python/Zope/App/Security/Grants/FSSync.py 1.1 => 1.2 ===
--- /dev/null	Fri Oct 11 02:28:07 2002
+++ Zope3/lib/python/Zope/App/Security/Grants/FSSync.py	Fri Oct 11 02:28:06 2002
@@ -0,0 +1,59 @@
+##############################################################################
+#
+# Copyright (c) 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+# 
+##############################################################################
+"""
+$Id$
+"""
+
+__metaclass__ = type
+
+from Zope.App.FSSync.IObjectFile import IObjectFile
+from Zope.App.FSSync.ObjectEntryAdapter import ObjectEntryAdapter
+from Zope.App.Security import Settings
+
+class ObjectFileAdapter(ObjectEntryAdapter):
+    "ObjectFile adapter for file objects"
+
+    __implements__ =  IObjectFile
+
+    def getBody(self):
+        "See Zope.App.FSSync.IObjectFile.IObjectFile"
+
+        r = []
+
+        for row, col, setting in self.context.getAllCells():
+            r.append('%s\t%s\t%s\n' % 
+                     (setting.getName(),
+                      row,
+                      col)
+                     )
+
+        return ''.join(r)
+
+    def setBody(self, body):
+        "See Zope.App.FSSync.IObjectFile.IObjectFile"
+
+        context = self.context
+
+        for row, col, setting in context.getAllCells():
+            context.delCell(row, col)
+        
+        for record in body.split('\n'):
+            record = record.strip()
+            if record:
+                setting, row, col = record.split()
+                context.addCell(row, col, getattr(Settings, setting))
+
+            
+
+__doc__ = ObjectFileAdapter.__doc__ + __doc__


=== Zope3/lib/python/Zope/App/Security/Grants/configure.zcml 1.3 => 1.3.8.1 ===
--- Zope3/lib/python/Zope/App/Security/Grants/configure.zcml:1.3	Tue Jun 25 11:27:52 2002
+++ Zope3/lib/python/Zope/App/Security/Grants/configure.zcml	Fri Oct 11 02:28:06 2002
@@ -32,5 +32,10 @@
            provides=".IPrincipalPermissionManager."
            for="Zope.App.OFS.Annotation.IAnnotatable." />
 
+  <adapter factory=".Grants.FSSync.ObjectFileAdapter"
+           provides="Zope.App.FSSync.IObjectFile."
+           for="Zope.App.Security.Grants.ILocalSecurityMap."
+           />
+
 </zopeConfigure>