[Zope3-checkins] CVS: Zope3/src/zope/app/content - fssync.py:1.1.2.1 configure.zcml:1.12.4.1
Guido van Rossum
guido@python.org
Thu, 1 May 2003 17:38:09 -0400
Update of /cvs-repository/Zope3/src/zope/app/content
In directory cvs.zope.org:/tmp/cvs-serv17673
Modified Files:
Tag: fssync-branch
configure.zcml
Added Files:
Tag: fssync-branch
fssync.py
Log Message:
Add fssync adapters and corresponding directives.
=== Added File Zope3/src/zope/app/content/fssync.py ===
##############################################################################
#
# 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: fssync.py,v 1.1.2.1 2003/05/01 21:38:09 gvanrossum Exp $
"""
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.12.4.1 ===
--- Zope3/src/zope/app/content/configure.zcml:1.12 Wed Apr 9 07:47:52 2003
+++ Zope3/src/zope/app/content/configure.zcml Thu May 1 17:38:09 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 -->