[Zope3-checkins] SVN: Zope3/trunk/ very carefully,
split the fssync adapters for zope.app.folder into a
Fred L. Drake, Jr.
fred at zope.com
Tue May 25 12:58:30 EDT 2004
Log message for revision 24963:
very carefully, split the fssync adapters for zope.app.folder into a
separate, optional package
-=-
Added: Zope3/trunk/package-includes/zope.app.folder.fssync-configure.zcml
===================================================================
--- Zope3/trunk/package-includes/zope.app.folder.fssync-configure.zcml 2004-05-25 13:58:35 UTC (rev 24962)
+++ Zope3/trunk/package-includes/zope.app.folder.fssync-configure.zcml 2004-05-25 16:58:29 UTC (rev 24963)
@@ -0,0 +1 @@
+<include package="zope.app.folder.fssync" />
Property changes on: Zope3/trunk/package-includes/zope.app.folder.fssync-configure.zcml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Added: Zope3/trunk/src/zope/app/folder/PACKAGE.cfg
===================================================================
--- Zope3/trunk/src/zope/app/folder/PACKAGE.cfg 2004-05-25 13:58:35 UTC (rev 24962)
+++ Zope3/trunk/src/zope/app/folder/PACKAGE.cfg 2004-05-25 16:58:29 UTC (rev 24963)
@@ -0,0 +1,5 @@
+# The fssync adapater is a separate component.
+
+<collection>
+ fssync -
+</collection>
Modified: Zope3/trunk/src/zope/app/folder/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/folder/configure.zcml 2004-05-25 13:58:35 UTC (rev 24962)
+++ Zope3/trunk/src/zope/app/folder/configure.zcml 2004-05-25 16:58:29 UTC (rev 24963)
@@ -1,6 +1,5 @@
<configure
xmlns="http://namespaces.zope.org/zope"
- xmlns:fssync='http://namespaces.zope.org/fssync'
i18n_domain="zope"
>
@@ -32,9 +31,6 @@
/>
</content>
-
- <!-- fssync directives -->
-
<adapter
for=".interfaces.IFolder"
provides="zope.app.filerepresentation.interfaces.IDirectoryFactory"
@@ -45,16 +41,11 @@
<adapter
for=".interfaces.IFolder"
provides="zope.app.filerepresentation.interfaces.IReadDirectory"
- factory=".fssync.ReadDirectory"
+ factory=".filerepresentation.ReadDirectory"
permission="zope.View"
/>
- <fssync:adapter
- class=".folder.Folder"
- factory=".fssync.FolderAdapter"
- />
-
<!-- include browser package -->
<include package=".browser" />
Added: Zope3/trunk/src/zope/app/folder/filerepresentation.py
===================================================================
--- Zope3/trunk/src/zope/app/folder/filerepresentation.py 2004-05-25 13:58:35 UTC (rev 24962)
+++ Zope3/trunk/src/zope/app/folder/filerepresentation.py 2004-05-25 16:58:29 UTC (rev 24963)
@@ -0,0 +1,73 @@
+##############################################################################
+#
+# 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 representation support.
+
+$Id$
+"""
+
+from zope.app.site.interfaces import ISite
+
+
+class RootDirectoryFactory(object):
+
+ def __init__(self, context):
+ pass
+
+ def __call__(self, name):
+ return Folder()
+
+
+class ReadDirectory(object):
+ """Adapter to provide a file-system rendition of folders
+ """
+
+ def __init__(self, context):
+ self.context = context
+
+ def keys(self):
+ keys = self.context.keys()
+ if ISite.providedBy(self.context):
+ return list(keys) + ['++etc++site']
+ return keys
+
+ def get(self, key, default=None):
+ if key == '++etc++site' and ISite.providedBy(self.context):
+ return self.context.getSiteManager()
+
+ return self.context.get(key, default)
+
+ def __iter__(self):
+ return iter(self.keys())
+
+ def __getitem__(self, key):
+ v = self.get(key, self)
+ if v is self:
+ raise KeyError, key
+ return v
+
+ def values(self):
+ return map(self.get, self.keys())
+
+ def __len__(self):
+ l = len(self.context)
+ if ISite.providedBy(self.context):
+ l += 1
+ return l
+
+ def items(self):
+ get = self.get
+ return [(key, get(key)) for key in self.keys()]
+
+ def __contains__(self, key):
+ return self.get(key) is not None
Property changes on: Zope3/trunk/src/zope/app/folder/filerepresentation.py
___________________________________________________________________
Name: svn:mime-type
+ text/x-python
Name: svn:eol-style
+ native
Added: Zope3/trunk/src/zope/app/folder/fssync/SETUP.cfg
===================================================================
--- Zope3/trunk/src/zope/app/folder/fssync/SETUP.cfg 2004-05-25 13:58:35 UTC (rev 24962)
+++ Zope3/trunk/src/zope/app/folder/fssync/SETUP.cfg 2004-05-25 16:58:29 UTC (rev 24963)
@@ -0,0 +1,3 @@
+<data-files skel/etc/package-includes>
+ zope.app.folder.fssync-configure.zcml
+</data-files>
Added: Zope3/trunk/src/zope/app/folder/fssync/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/folder/fssync/__init__.py 2004-05-25 13:58:35 UTC (rev 24962)
+++ Zope3/trunk/src/zope/app/folder/fssync/__init__.py 2004-05-25 16:58:29 UTC (rev 24963)
@@ -0,0 +1 @@
+# This directory is a Python package.
Property changes on: Zope3/trunk/src/zope/app/folder/fssync/__init__.py
___________________________________________________________________
Name: svn:mime-type
+ text/x-python
Name: svn:eol-style
+ native
Added: Zope3/trunk/src/zope/app/folder/fssync/adapter.py
===================================================================
--- Zope3/trunk/src/zope/app/folder/fssync/adapter.py 2004-05-25 13:58:35 UTC (rev 24962)
+++ Zope3/trunk/src/zope/app/folder/fssync/adapter.py 2004-05-25 16:58:29 UTC (rev 24963)
@@ -0,0 +1,62 @@
+##############################################################################
+#
+# 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.fssync.server.entryadapter import DirectoryAdapter
+from zope.app.site.interfaces import ISite
+
+
+class FolderAdapter(DirectoryAdapter):
+ """Adapter to provide an fssync interpretation of folders
+ """
+
+ def contents(self):
+ """Compute a folder listing.
+
+ A folder listing is a list of the items in the folder. It is
+ a combination of the folder contents and the site-manager, if
+ a folder is a site.
+
+ The adapter will take any mapping:
+
+ >>> adapter = FolderAdapter({'x': 1, 'y': 2})
+ >>> contents = adapter.contents()
+ >>> contents.sort()
+ >>> contents
+ [('x', 1), ('y', 2)]
+
+ If a folder is a site, then we'll get ++etc++site included:
+
+ >>> import zope.interface
+ >>> class Site(dict):
+ ... zope.interface.implements(ISite)
+ ...
+ ... def getSiteManager(self):
+ ... return 'site goes here :)'
+
+ >>> adapter = FolderAdapter(Site({'x': 1, 'y': 2}))
+ >>> contents = adapter.contents()
+ >>> contents.sort()
+ >>> contents
+ [('++etc++site', 'site goes here :)'), ('x', 1), ('y', 2)]
+
+ """
+ result = super(FolderAdapter, self).contents()
+ if ISite.providedBy(self.context):
+ sm = self.context.getSiteManager()
+ result.append(('++etc++site', sm))
+ return result
Property changes on: Zope3/trunk/src/zope/app/folder/fssync/adapter.py
___________________________________________________________________
Name: svn:mime-type
+ text/x-python
Name: svn:eol-style
+ native
Added: Zope3/trunk/src/zope/app/folder/fssync/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/folder/fssync/configure.zcml 2004-05-25 13:58:35 UTC (rev 24962)
+++ Zope3/trunk/src/zope/app/folder/fssync/configure.zcml 2004-05-25 16:58:29 UTC (rev 24963)
@@ -0,0 +1,12 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:fssync='http://namespaces.zope.org/fssync'
+ i18n_domain="zope"
+ >
+
+ <fssync:adapter
+ class="zope.app.folder.Folder"
+ factory=".adapter.FolderAdapter"
+ />
+
+</configure>
Property changes on: Zope3/trunk/src/zope/app/folder/fssync/configure.zcml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Added: Zope3/trunk/src/zope/app/folder/fssync/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/folder/fssync/tests.py 2004-05-25 13:58:35 UTC (rev 24962)
+++ Zope3/trunk/src/zope/app/folder/fssync/tests.py 2004-05-25 16:58:29 UTC (rev 24963)
@@ -0,0 +1,28 @@
+##############################################################################
+#
+# Copyright (c) 2001, 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.
+#
+##############################################################################
+"""Tests for zope.app.folder.fssync.adapter.
+
+$Id$
+"""
+
+import unittest
+
+from zope.testing.doctestunit import DocTestSuite
+
+
+def test_suite():
+ return DocTestSuite('zope.app.folder.fssync.adapter')
+
+if __name__=='__main__':
+ unittest.main(defaultTest='test_suite')
Property changes on: Zope3/trunk/src/zope/app/folder/fssync/tests.py
___________________________________________________________________
Name: svn:mime-type
+ text/x-python
Name: svn:eol-style
+ native
Added: Zope3/trunk/src/zope/app/folder/fssync/zope.app.folder.fssync-configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/folder/fssync/zope.app.folder.fssync-configure.zcml 2004-05-25 13:58:35 UTC (rev 24962)
+++ Zope3/trunk/src/zope/app/folder/fssync/zope.app.folder.fssync-configure.zcml 2004-05-25 16:58:29 UTC (rev 24963)
@@ -0,0 +1 @@
+<include package="zope.app.folder.fssync" />
Property changes on: Zope3/trunk/src/zope/app/folder/fssync/zope.app.folder.fssync-configure.zcml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Deleted: Zope3/trunk/src/zope/app/folder/fssync.py
===================================================================
--- Zope3/trunk/src/zope/app/folder/fssync.py 2004-05-25 13:58:35 UTC (rev 24962)
+++ Zope3/trunk/src/zope/app/folder/fssync.py 2004-05-25 16:58:29 UTC (rev 24963)
@@ -1,115 +0,0 @@
-##############################################################################
-#
-# 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.fssync.server.entryadapter import DirectoryAdapter
-from zope.app.site.interfaces import ISite
-
-__metaclass__ = type
-
-class RootDirectoryFactory:
-
- def __init__(self, context):
- pass
-
- def __call__(self, name):
- return Folder()
-
-class ReadDirectory:
- """Adapter to provide a file-system rendition of folders
- """
-
- def __init__(self, context):
- self.context = context
-
- def keys(self):
- keys = self.context.keys()
- if ISite.providedBy(self.context):
- return list(keys) + ['++etc++site']
- return keys
-
- def get(self, key, default=None):
- if key == '++etc++site' and ISite.providedBy(self.context):
- return self.context.getSiteManager()
-
- return self.context.get(key, default)
-
- def __iter__(self):
- return iter(self.keys())
-
- def __getitem__(self, key):
- v = self.get(key, self)
- if v is self:
- raise KeyError, key
- return v
-
- def values(self):
- return map(self.get, self.keys())
-
- def __len__(self):
- l = len(self.context)
- if ISite.providedBy(self.context):
- l += 1
- return l
-
- def items(self):
- get = self.get
- return [(key, get(key)) for key in self.keys()]
-
- def __contains__(self, key):
- return self.get(key) is not None
-
-class FolderAdapter(DirectoryAdapter):
- """Adapter to provide an fssync interpretation of folders
- """
-
- def contents(self):
- """Compute a folder listing.
-
- A folder listing is a list of the items in the folder. It is
- a combination of the folder contents and the site-manager, if
- a folder is a site.
-
- The adapter will take any mapping:
-
- >>> adapter = FolderAdapter({'x': 1, 'y': 2})
- >>> contents = adapter.contents()
- >>> contents.sort()
- >>> contents
- [('x', 1), ('y', 2)]
-
- If a folder is a site, then we'll get ++etc++site included:
-
- >>> import zope.interface
- >>> class Site(dict):
- ... zope.interface.implements(ISite)
- ...
- ... def getSiteManager(self):
- ... return 'site goes here :)'
-
- >>> adapter = FolderAdapter(Site({'x': 1, 'y': 2}))
- >>> contents = adapter.contents()
- >>> contents.sort()
- >>> contents
- [('++etc++site', 'site goes here :)'), ('x', 1), ('y', 2)]
-
- """
- result = super(FolderAdapter, self).contents()
- if ISite.providedBy(self.context):
- sm = self.context.getSiteManager()
- result.append(('++etc++site', sm))
- return result
Modified: Zope3/trunk/src/zope/app/folder/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/folder/tests.py 2004-05-25 13:58:35 UTC (rev 24962)
+++ Zope3/trunk/src/zope/app/folder/tests.py 2004-05-25 16:58:29 UTC (rev 24963)
@@ -57,7 +57,6 @@
return TestSuite((
makeSuite(Test),
makeSuite(FolderMetaDataTest),
- DocTestSuite('zope.app.folder.fssync'),
))
if __name__=='__main__':
More information about the Zope3-Checkins
mailing list