[Zope3-checkins] CVS: Zope3/src/zope/app/content - fssync.py:1.2 configure.zcml:1.13

Guido van Rossum guido@python.org
Mon, 5 May 2003 14:01:31 -0400


Update of /cvs-repository/Zope3/src/zope/app/content
In directory cvs.zope.org:/tmp/cvs-serv2527/src/zope/app/content

Modified Files:
	configure.zcml 
Added Files:
	fssync.py 
Log Message:
Merge fssync stuff back to trunk.  A few things actually work (I
successfully did a checkout of some files and diffed them; though
commit doesn't seem to work yet), and you know how I love long-living
branches....



=== Zope3/src/zope/app/content/fssync.py 1.1 => 1.2 ===
--- /dev/null	Mon May  5 14:01:31 2003
+++ Zope3/src/zope/app/content/fssync.py	Mon May  5 14:01:00 2003
@@ -0,0 +1,66 @@
+##############################################################################
+#
+# 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.
+# 
+##############################################################################
+"""Filesystem synchronization support.
+
+$Id$
+"""
+
+from zope.app.interfaces.fssync import IObjectFile, IContentDirectory
+from zope.app.fssync.classes import ObjectEntryAdapter, AttrMapping
+from zope.proxy.context import ContextWrapper
+
+_attrs = ('contentType', )
+
+class ObjectFileAdapter(ObjectEntryAdapter):
+    """ObjectFile adapter for file objects."""
+
+    __implements__ =  IObjectFile
+
+    def getBody(self):
+        "See IObjectFile"
+        return self.context.getData()
+
+    def setBody(self, data):
+        "See IObjectFile"
+        self.context.setData(data)
+
+    def extra(self):
+        "See IObjectEntry"
+        return AttrMapping(self.context, _attrs)
+
+class ObjectDirectory(ObjectEntryAdapter):
+    """Folder adapter to provide a file-system representation."""
+
+    __implements__ =  IContentDirectory
+
+    def contents(self):
+        "See IObjectDirectory"
+        result = []
+        for name, object in self.context.items():
+            object = ContextWrapper(object, self.context, name=name)
+            result.append((name, object))
+        return result
+
+class ZPTObjectFileAdapter(ObjectEntryAdapter):
+    """ObjectFile adapter for ZPT page objects."""
+
+    __implements__ =  IObjectFile
+
+    def getBody(self):
+        "See IObjectFile"
+        return self.context.getSource()
+
+    def setBody(self, data):
+        "See IObjectFile"
+        self.context.setSource(data)


=== Zope3/src/zope/app/content/configure.zcml 1.12 => 1.13 ===
--- Zope3/src/zope/app/content/configure.zcml:1.12	Wed Apr  9 07:47:52 2003
+++ Zope3/src/zope/app/content/configure.zcml	Mon May  5 14:01:00 2003
@@ -1,6 +1,7 @@
 <zopeConfigure
    xmlns='http://namespaces.zope.org/zope'
    xmlns:browser='http://namespaces.zope.org/browser'
+   xmlns:fssync='http://namespaces.zope.org/fssync'
 >
 
 <!-- Simple Folder Directives -->
@@ -352,6 +353,37 @@
 
 </content>
 
+<!-- Filesystem Synchronization -->
+
+  <!-- fssync:adapter directives -->
+
+<fssync:adapter factory="zope.app.fssync.classes.Default" />
+
+<fssync:adapter class=".file.File" factory=".fssync.ObjectFileAdapter" />
+
+<fssync:adapter class=".folder.Folder" factory=".fssync.ObjectDirectory" />
+
+<fssync:adapter class=".zpt.ZPTPage" factory=".fssync.ZPTObjectFileAdapter" />
+
+  <!-- zope:adapter directives -->
+
+<adapter
+  for="zope.app.interfaces.content.file.IFile"
+  factory=".fssync.ObjectFileAdapter"
+  provides="zope.app.interfaces.fssync.IObjectFile"
+  />
+
+<adapter
+  for="zope.app.interfaces.content.folder.IFolder"
+  factory=".fssync.ObjectDirectory"
+  provides="zope.app.interfaces.fssync.IObjectDirectory"
+  />
+
+<adapter
+  for="zope.app.interfaces.content.zpt.IZPTPage"
+  factory=".fssync.ObjectFileAdapter"
+  provides="zope.app.interfaces.fssync.IObjectFile"
+  />
 
 <!-- Further Directives -->