[Checkins] SVN: Zope3/trunk/src/zope/ Removed
zope.app.fssync.fsregistry and the related fssync zcml
directives. Synchronizers are now registered as named
utilities. See the new registration.txt for details.
Uwe Oestermeier
uwe_oestermeier at iwm-kmrc.de
Thu Feb 8 02:48:59 EST 2007
Log message for revision 72447:
Removed zope.app.fssync.fsregistry and the related fssync zcml directives. Synchronizers are now registered as named utilities. See the new registration.txt for details.
Changed:
U Zope3/trunk/src/zope/app/dtmlpage/fssync/configure.zcml
U Zope3/trunk/src/zope/app/file/fssync/configure.zcml
U Zope3/trunk/src/zope/app/folder/fssync/configure.zcml
U Zope3/trunk/src/zope/app/fssync/configure.zcml
U Zope3/trunk/src/zope/app/fssync/fspickle.py
D Zope3/trunk/src/zope/app/fssync/fsregistry.py
U Zope3/trunk/src/zope/app/fssync/interfaces.py
D Zope3/trunk/src/zope/app/fssync/meta.zcml
D Zope3/trunk/src/zope/app/fssync/metaconfigure.py
D Zope3/trunk/src/zope/app/fssync/metadirectives.py
A Zope3/trunk/src/zope/app/fssync/registration.txt
U Zope3/trunk/src/zope/app/fssync/syncer.py
D Zope3/trunk/src/zope/app/fssync/tests/fssync.zcml
D Zope3/trunk/src/zope/app/fssync/tests/fssync_duplicate.zcml
U Zope3/trunk/src/zope/app/fssync/tests/test_committer.py
D Zope3/trunk/src/zope/app/fssync/tests/test_fsdirective.py
D Zope3/trunk/src/zope/app/fssync/tests/test_fsregistry.py
A Zope3/trunk/src/zope/app/fssync/tests/test_registration.py
D Zope3/trunk/src/zope/app/fssync/zope.app.fssync-meta.zcml
U Zope3/trunk/src/zope/app/module/fssync/configure.zcml
U Zope3/trunk/src/zope/app/zptpage/fssync/configure.zcml
U Zope3/trunk/src/zope/dublincore/fssync/configure.zcml
-=-
Modified: Zope3/trunk/src/zope/app/dtmlpage/fssync/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/dtmlpage/fssync/configure.zcml 2007-02-08 06:51:24 UTC (rev 72446)
+++ Zope3/trunk/src/zope/app/dtmlpage/fssync/configure.zcml 2007-02-08 07:48:58 UTC (rev 72447)
@@ -1,12 +1,13 @@
<configure
xmlns='http://namespaces.zope.org/zope'
- xmlns:fssync='http://namespaces.zope.org/fssync'
i18n_domain='zope'
>
- <fssync:adapter
- class="zope.app.dtmlpage.dtmlpage.DTMLPage"
- factory=".adapter.DTMLPageAdapter"
+ <utility
+ component=".adapter.DTMLPageAdapter"
+ provides="zope.app.fssync.interfaces.IFSSyncFactory"
+ name="zope.app.dtmlpage.dtmlpage.DTMLPage"
+ permission="zope.ManageContent"
/>
</configure>
Modified: Zope3/trunk/src/zope/app/file/fssync/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/file/fssync/configure.zcml 2007-02-08 06:51:24 UTC (rev 72446)
+++ Zope3/trunk/src/zope/app/file/fssync/configure.zcml 2007-02-08 07:48:58 UTC (rev 72447)
@@ -1,17 +1,20 @@
<configure
xmlns='http://namespaces.zope.org/zope'
- xmlns:fssync='http://namespaces.zope.org/fssync'
i18n_domain='zope'
>
- <fssync:adapter
- class="zope.app.file.File"
- factory=".adapter.FileAdapter"
+ <utility
+ component=".adapter.FileAdapter"
+ name="zope.app.file.File"
+ provides="zope.app.fssync.interfaces.IFSSyncFactory"
+ permission="zope.ManageContent"
/>
- <fssync:adapter
- class="zope.app.file.Image"
- factory=".adapter.FileAdapter"
+ <utility
+ component=".adapter.FileAdapter"
+ name="zope.app.file.Image"
+ provides="zope.app.fssync.interfaces.IFSSyncFactory"
+ permission="zope.ManageContent"
/>
</configure>
Modified: Zope3/trunk/src/zope/app/folder/fssync/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/folder/fssync/configure.zcml 2007-02-08 06:51:24 UTC (rev 72446)
+++ Zope3/trunk/src/zope/app/folder/fssync/configure.zcml 2007-02-08 07:48:58 UTC (rev 72447)
@@ -1,12 +1,13 @@
<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"
+ <utility
+ component=".adapter.FolderAdapter"
+ name="zope.app.folder.folder.Folder"
+ provides="zope.app.fssync.interfaces.IFSSyncFactory"
+ permission="zope.ManageContent"
/>
</configure>
Modified: Zope3/trunk/src/zope/app/fssync/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/fssync/configure.zcml 2007-02-08 06:51:24 UTC (rev 72446)
+++ Zope3/trunk/src/zope/app/fssync/configure.zcml 2007-02-08 07:48:58 UTC (rev 72447)
@@ -18,16 +18,13 @@
/>
</class>
-
+
<utility
- provides="zope.app.fssync.interfaces.IGlobalFSSyncUtility"
- component="zope.app.fssync.fsregistry.fsRegistry"
+ component="zope.fssync.server.entryadapter.DefaultFileAdapter"
+ provides="zope.app.fssync.interfaces.IFSSyncFactory"
+ permission="zope.ManageContent"
/>
- <fssync:adapter
- factory="zope.fssync.server.entryadapter.DefaultFileAdapter"
- />
-
<!-- Include browser package -->
Modified: Zope3/trunk/src/zope/app/fssync/fspickle.py
===================================================================
--- Zope3/trunk/src/zope/app/fssync/fspickle.py 2007-02-08 06:51:24 UTC (rev 72446)
+++ Zope3/trunk/src/zope/app/fssync/fspickle.py 2007-02-08 07:48:58 UTC (rev 72447)
@@ -146,6 +146,9 @@
return PARENT_MARKER
elif location.inside(object, self.root):
return LocationPhysicallyLocatable(object).getPath()
+ elif object.__parent__ is None:
+ return None
+
raise ValueError(
"object implementing ILocation found outside tree")
else:
Deleted: Zope3/trunk/src/zope/app/fssync/fsregistry.py
===================================================================
--- Zope3/trunk/src/zope/app/fssync/fsregistry.py 2007-02-08 06:51:24 UTC (rev 72446)
+++ Zope3/trunk/src/zope/app/fssync/fsregistry.py 2007-02-08 07:48:58 UTC (rev 72447)
@@ -1,79 +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.1 (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 registry.
-
-This acts as a global (placeless) utility.
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from zope.exceptions import DuplicationError
-from zope.interface import implements
-from zope.app.fssync.interfaces import IGlobalFSSyncUtility
-from zope.app.fssync.interfaces import IFactoryNotFoundError
-
-class FactoryNotFoundError(LookupError):
- implements(IFactoryNotFoundError)
-
-class FSRegistry(object):
- """Registry Wrapper class.
-
- This is a maping from Class -> Serializer Factory Method.
- """
-
- implements(IGlobalFSSyncUtility)
-
- def __init__(self):
- self._class_factory_reg = {}
-
- def __call__(self):
- return self.__init__()
-
- def getSynchronizer(self, object):
- """Return factory method for a given class.
-
- If no factory is registered for the given class, return the
- default factory, if one has been registered. If no default
- factory has been registered, raise ``FactoryNotFoundError``.
- """
-
- factory = self._class_factory_reg.get(object.__class__)
- if factory is None:
- factory = self._class_factory_reg.get(None)
- if factory is None:
- raise FactoryNotFoundError
- return factory(object)
-
- def provideSynchronizer(self,class_, factory):
- """Set `class_`, factory into the dictionary."""
- if class_ in self._class_factory_reg:
- raise DuplicationError
- else:
- self._class_factory_reg[class_] = factory
-
- _clear = __init__
-
-
-# The FS registry serializer utility instance
-fsRegistry = FSRegistry()
-provideSynchronizer = fsRegistry.provideSynchronizer
-getSynchronizer = fsRegistry.getSynchronizer
-
-_clear = fsRegistry._clear
-
-# Register our cleanup with Testing.CleanUp to make writing unit tests simpler.
-from zope.testing.cleanup import addCleanUp
-addCleanUp(_clear)
-del addCleanUp
Modified: Zope3/trunk/src/zope/app/fssync/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/fssync/interfaces.py 2007-02-08 06:51:24 UTC (rev 72446)
+++ Zope3/trunk/src/zope/app/fssync/interfaces.py 2007-02-08 07:48:58 UTC (rev 72447)
@@ -17,44 +17,36 @@
"""
__docformat__ = 'restructuredtext'
-from zope.interface import Interface
-from zope.annotation.interfaces import IAnnotations
+from zope import interface
+from zope import component
+from zope import annotation
-class IFSSyncAnnotations(IAnnotations):
+class IFSSyncAnnotations(annotation.interfaces.IAnnotations):
"""Access to synchronizable annotations."""
def __iter__():
"""Iterates over the package-unique keys."""
-class IFactoryNotFoundError(Interface):
- pass
+class IFSSyncFactory(component.interfaces.IFactory):
+ """A factory for file-system representation adapters.
+
+ This factory should be registered as a named utility with the dotted name of
+ the adapted class as the lookup key.
+
+ The default factory should be registered without a name.
+
+ The call of the factory should return
+
+ - an `IDirectoryEntry` adapter for the object if the
+ object is represented as a directory on the file system.
-class IFSSyncUtility(Interface):
- """Lookup file-system representation adapters."""
+ - an `IFileEntry` adapter for the object if the
+ object is represented as a file on the file system.
- def getSynchronizer(object):
- """Return an object that implements `IObjectEntry` for the argument.
+ or
- The return value may be:
-
- - An `IDirectoryEntry` adapter for the object is returned if the
- object is represented as a directory on the file system.
-
- - An `IFileEntry` adapter for the object is returned if the
- object is represented as a file on the file system.
-
- or
-
- - Default, if no synchronizser has been registered.
- """
-
-
-class IGlobalFSSyncUtility(IFSSyncUtility):
- """Global registry for file-system representation adapters."""
-
- def provideSynchronizer(class_, factory):
- """Register a synchronizer.
-
- A factory for a Synchronization Adapter is provided to create
- synchronizers for instances of the class.
- """
+ - default, if no special synchronizser has been registered.
+
+ See registration.txt for further explanations.
+ """
+
Deleted: Zope3/trunk/src/zope/app/fssync/meta.zcml
===================================================================
--- Zope3/trunk/src/zope/app/fssync/meta.zcml 2007-02-08 06:51:24 UTC (rev 72446)
+++ Zope3/trunk/src/zope/app/fssync/meta.zcml 2007-02-08 07:48:58 UTC (rev 72447)
@@ -1,11 +0,0 @@
-<configure
- xmlns="http://namespaces.zope.org/zope"
- xmlns:meta="http://namespaces.zope.org/meta">
-
- <meta:directive
- namespace="http://namespaces.zope.org/fssync"
- name="adapter"
- schema=".metadirectives.IAdapterDirective"
- handler=".metaconfigure.registerFSRegistry"/>
-
-</configure>
Deleted: Zope3/trunk/src/zope/app/fssync/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/fssync/metaconfigure.py 2007-02-08 06:51:24 UTC (rev 72446)
+++ Zope3/trunk/src/zope/app/fssync/metaconfigure.py 2007-02-08 07:48:58 UTC (rev 72447)
@@ -1,29 +0,0 @@
-##############################################################################
-#
-# 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.1 (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.
-#
-##############################################################################
-""" Register class directive.
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from zope.app.fssync.fsregistry import provideSynchronizer
-
-def registerFSRegistry(_context, class_=None, factory=None):
- """`registerFSRegistry` method to register Class and Serializer factory
- associated with it.
- """
- _context.action(
- discriminator=('adapter', class_),
- callable=provideSynchronizer,
- args=(class_, factory) )
Deleted: Zope3/trunk/src/zope/app/fssync/metadirectives.py
===================================================================
--- Zope3/trunk/src/zope/app/fssync/metadirectives.py 2007-02-08 06:51:24 UTC (rev 72446)
+++ Zope3/trunk/src/zope/app/fssync/metadirectives.py 2007-02-08 07:48:58 UTC (rev 72447)
@@ -1,40 +0,0 @@
-##############################################################################
-#
-# 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.1 (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.
-#
-##############################################################################
-"""Fssync Directive Schemas
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from zope.configuration.fields import GlobalObject
-from zope.interface import Interface
-
-class IAdapterDirective(Interface):
- """Define a FS Sync adapter.
-
- Define an adapter for an object that is used to create filesystem
- representation of the component.
- """
-
- class_ = GlobalObject(
- title=u"Class",
- description=u"Specifies the class for which this adapter is " \
- u"registered.",
- required=False)
-
- factory = GlobalObject(
- title=u"Factory",
- description=u"Specifies the factory that will create the adapter.",
- required=True)
-
Added: Zope3/trunk/src/zope/app/fssync/registration.txt
===================================================================
--- Zope3/trunk/src/zope/app/fssync/registration.txt 2007-02-08 06:51:24 UTC (rev 72446)
+++ Zope3/trunk/src/zope/app/fssync/registration.txt 2007-02-08 07:48:58 UTC (rev 72447)
@@ -0,0 +1,70 @@
+Registration of Synchronizers
+=============================
+
+The fssync package exchanges serialized objects between Zope and the
+local filesystem. This is usefull in at least two cases:
+
+- data export / import (e.g. moving objects from one server to another)
+- content management (e.g. managing a wiki or other collections of
+documents offline)
+
+In the first case it is crucial that fssync is able to serialize "all"
+object data. Note that it isn't always obvious what data is intrinsic
+to an object. Therefore we must provide special serialization /
+de-serialization adapters which take care of writing and reading "all"
+data. An obvious solution would be to use inheriting synchronization
+adapters. But this solution bears a risk. If someone created a subclass
+and forgot to create an adapter, then their data would be serialized
+incompletely.
+
+A better solution is to provide class based adapters for special object
+types and a default serializer which tries to capture
+the forgotten serialization specifications of subclasses.
+
+>>> from zope import component
+>>> from interfaces import IFSSyncFactory
+>>> from zope.app.fssync.tests import sampleclass
+>>> a = sampleclass.C1()
+>>> b = sampleclass.C2()
+
+The default adapter factory is registered as an unnamed utility:
+
+>>> component.provideUtility(sampleclass.CDefaultAdapter,
+... provides=IFSSyncFactory)
+
+
+All special serializers are registered for a specific class which is
+represented by the dotted class name in the factory registration:
+
+>>> dottedname1 = 'zope.app.fssync.tests.sampleclass.C1'
+>>> dottedname2 = 'zope.app.fssync.tests.sampleclass.C2'
+>>> component.provideUtility(sampleclass.CFileAdapter,
+... provides=IFSSyncFactory, name=dottedname1)
+
+
+>>> sa = component.getUtility(IFSSyncFactory, dottedname1)(a)
+>>> sa
+<zope.app.fssync.tests.sampleclass.CFileAdapter object at ...>
+
+>>> sb = component.getUtility(IFSSyncFactory, dottedname2)(b)
+Traceback (most recent call last):
+...
+ComponentLookupError: ...
+
+
+The syncer.getSerializer method ensures that we get the class based
+serializer or the default serializer:
+
+>>> from zope.app.fssync import syncer
+>>> syncer.getSerializer(a)
+<zope.app.fssync.tests.sampleclass.CFileAdapter object at ...>
+
+>>> syncer.getSerializer(b)
+<zope.app.fssync.tests.sampleclass.CDefaultAdapter object at ...>
+
+
+
+To Dos
+======
+
+The zcml fssync namespace is no longer needed.
Modified: Zope3/trunk/src/zope/app/fssync/syncer.py
===================================================================
--- Zope3/trunk/src/zope/app/fssync/syncer.py 2007-02-08 06:51:24 UTC (rev 72446)
+++ Zope3/trunk/src/zope/app/fssync/syncer.py 2007-02-08 07:48:58 UTC (rev 72447)
@@ -17,29 +17,48 @@
"""
__docformat__ = 'restructuredtext'
-from zope.app import zapi
-from zope.interface import implements
+from zope import interface
+from zope import component
from zope.traversing.api import getPath
from zope.annotation.interfaces import IAnnotations
from zope.annotation.attribute import AttributeAnnotations
from zope.fssync.server.syncer import Syncer
-from zope.app.fssync.interfaces import IGlobalFSSyncUtility
+from zope.app.fssync.interfaces import IFSSyncFactory
from interfaces import IFSSyncAnnotations
+def dottedname(klass):
+ return "%s.%s" % (klass.__module__, klass.__name__)
+
class FSSyncAnnotations(AttributeAnnotations):
"""Default adapter for access to attribute annotations.
Should be registered as trusted adapter.
"""
- implements(IFSSyncAnnotations)
+ interface.implements(IFSSyncAnnotations)
+def provideSynchronizer(klass, factory):
+ if klass is not None:
+ name = dottedname(klass)
+ else:
+ name = ''
+ component.provideUtility(factory, provides=IFSSyncFactory, name=name)
+
+
def getObjectId(obj):
return getPath(obj)
def getSerializer(obj):
- syncUtility = zapi.getUtility(IGlobalFSSyncUtility)
- return syncUtility.getSynchronizer(obj)
+ """Returns a synchronizer.
+
+ Looks for a named factory first and returns a default adapter
+ if the dotted class name is not known.
+ """
+ name = dottedname(obj.__class__)
+ factory = component.queryUtility(IFSSyncFactory, name=name)
+ if factory is None:
+ factory = component.getUtility(IFSSyncFactory)
+ return factory(obj)
def getAnnotations(obj):
return IFSSyncAnnotations(obj, None)
Deleted: Zope3/trunk/src/zope/app/fssync/tests/fssync.zcml
===================================================================
--- Zope3/trunk/src/zope/app/fssync/tests/fssync.zcml 2007-02-08 06:51:24 UTC (rev 72446)
+++ Zope3/trunk/src/zope/app/fssync/tests/fssync.zcml 2007-02-08 07:48:58 UTC (rev 72447)
@@ -1,13 +0,0 @@
-<configure xmlns="http://namespaces.zope.org/zope"
- xmlns:fssync="http://namespaces.zope.org/fssync">
-
- <include package="zope.app.fssync" file="meta.zcml"/>
-
- <fssync:adapter
- factory = "zope.app.fssync.tests.sampleclass.CDefaultAdapter"/>
-
- <fssync:adapter
- class=".sampleclass.C2"
- factory=".sampleclass.CDirAdapter"/>
-
-</configure>
Deleted: Zope3/trunk/src/zope/app/fssync/tests/fssync_duplicate.zcml
===================================================================
--- Zope3/trunk/src/zope/app/fssync/tests/fssync_duplicate.zcml 2007-02-08 06:51:24 UTC (rev 72446)
+++ Zope3/trunk/src/zope/app/fssync/tests/fssync_duplicate.zcml 2007-02-08 07:48:58 UTC (rev 72447)
@@ -1,14 +0,0 @@
-<configure xmlns="http://namespaces.zope.org/zope"
- xmlns:fssync="http://namespaces.zope.org/fssync">
-
- <include package="zope.app.fssync" file="meta.zcml"/>
-
- <fssync:adapter
- class="zope.app.fssync.tests.sampleclass.C1"
- factory="zope.app.fssync.tests.sampleclass.CDirAdapter" />
-
- <fssync:adapter
- class="zope.app.fssync.tests.sampleclass.C1"
- factory="zope.app.fssync.tests.sampleclass.CFileAdapter" />
-
-</configure>
Modified: Zope3/trunk/src/zope/app/fssync/tests/test_committer.py
===================================================================
--- Zope3/trunk/src/zope/app/fssync/tests/test_committer.py 2007-02-08 06:51:24 UTC (rev 72446)
+++ Zope3/trunk/src/zope/app/fssync/tests/test_committer.py 2007-02-08 07:48:58 UTC (rev 72447)
@@ -41,9 +41,7 @@
from zope.app.fssync import committer, syncer # The module
from zope.app.fssync.committer import Checker, Committer, SynchronizationError
-from zope.app.fssync.fsregistry import provideSynchronizer, fsRegistry
-
class Sample(object):
pass
@@ -117,9 +115,8 @@
def setUp(self):
super(TestBase, self).setUp()
- # Set up FSRegistryUtility
- zope.component.provideUtility(fsRegistry)
- provideSynchronizer(None, DefaultFileAdapter)
+ # Set up synchronizer factory
+ syncer.provideSynchronizer(None, DefaultFileAdapter)
# Set up temporary name administration
TempFiles.setUp(self)
@@ -230,7 +227,7 @@
self.assertEqual(container.value, "text/plain")
def test_create_object_factory_file(self):
- provideSynchronizer(dict, DictAdapter)
+ syncer.provideSynchronizer(dict, DictAdapter)
container = {}
entry = {"flag": "added", "factory": "__builtin__.dict"}
tfn = os.path.join(self.tempdir(), "foo")
@@ -240,7 +237,7 @@
self.assertEqual(container, {"foo": data})
def test_create_object_factory_directory(self):
- provideSynchronizer(PretendContainer, DirectoryAdapter)
+ syncer.provideSynchronizer(PretendContainer, DirectoryAdapter)
container = {}
entry = {"flag": "added", "factory": PCname}
tfn = os.path.join(self.tempdir(), "foo")
@@ -285,8 +282,8 @@
TestBase.setUp(self)
# Set up environment
- provideSynchronizer(PretendContainer, DirectoryAdapter)
- provideSynchronizer(dict, DictAdapter)
+ syncer.provideSynchronizer(PretendContainer, DirectoryAdapter)
+ syncer.provideSynchronizer(dict, DictAdapter)
zope.component.provideAdapter(file_factory_maker)
zope.component.provideAdapter(directory_factory_maker)
Deleted: Zope3/trunk/src/zope/app/fssync/tests/test_fsdirective.py
===================================================================
--- Zope3/trunk/src/zope/app/fssync/tests/test_fsdirective.py 2007-02-08 06:51:24 UTC (rev 72446)
+++ Zope3/trunk/src/zope/app/fssync/tests/test_fsdirective.py 2007-02-08 07:48:58 UTC (rev 72447)
@@ -1,53 +0,0 @@
-##############################################################################
-#
-# Copyright) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (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.
-#
-##############################################################################
-"""Test FSRegistry File-system synchronization utilities
-
-$Id$
-"""
-import unittest
-
-from zope.app.fssync.fsregistry import FactoryNotFoundError
-from zope.app.fssync.fsregistry import getSynchronizer
-from zope.app.fssync.tests.sampleclass import \
- C1, C2, CDirAdapter, CDefaultAdapter
-from zope.app.testing.placelesssetup import PlacelessSetup
-from zope.configuration import xmlconfig
-from zope.configuration.config import ConfigurationConflictError
-import zope.app.fssync.tests
-
-
-class DirectivesTest(PlacelessSetup, unittest.TestCase):
-
- def testFSDirective(self):
- # Register the adapter for the class
- self.assertRaises(FactoryNotFoundError, getSynchronizer, C2())
- self.context = xmlconfig.file("fssync.zcml", zope.app.fssync.tests)
- self.assertEqual(getSynchronizer(C2()).__class__, CDirAdapter)
-
- def testFSDirectiveDefaultAdapter(self):
- self.context = xmlconfig.file("fssync.zcml", zope.app.fssync.tests)
- self.assertEqual(getSynchronizer(C1()).__class__, CDefaultAdapter)
-
- def testFSDirectiveDuplicate(self):
- self.assertRaises(ConfigurationConflictError, xmlconfig.file,
- "fssync_duplicate.zcml", zope.app.fssync.tests)
-
-
-def test_suite():
- return unittest.TestSuite((
- unittest.makeSuite(DirectivesTest),
- ))
-
-if __name__ == '__main__':
- unittest.main()
Deleted: Zope3/trunk/src/zope/app/fssync/tests/test_fsregistry.py
===================================================================
--- Zope3/trunk/src/zope/app/fssync/tests/test_fsregistry.py 2007-02-08 06:51:24 UTC (rev 72446)
+++ Zope3/trunk/src/zope/app/fssync/tests/test_fsregistry.py 2007-02-08 07:48:58 UTC (rev 72447)
@@ -1,83 +0,0 @@
-##############################################################################
-#
-# Copyright) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (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.
-#
-##############################################################################
-"""Test FSRegistry File-system synchronization utilities
-
-$Id$
-"""
-
-from unittest import TestCase, TestSuite, main, makeSuite
-
-from zope.testing.cleanup import CleanUp
-from zope.interface.verify import verifyObject
-from zope.exceptions import DuplicationError
-
-from zope.app.fssync.interfaces import IGlobalFSSyncUtility
-
-from zope.app.fssync.fsregistry import getSynchronizer
-from zope.app.fssync.fsregistry import provideSynchronizer
-from zope.app.fssync.fsregistry import fsRegistry
-from zope.app.fssync.fsregistry import FactoryNotFoundError
-
-from zope.app.fssync.tests.sampleclass \
- import C1, C2, CDirAdapter, CFileAdapter, CDefaultAdapter
-
-class Test(CleanUp, TestCase):
- """Test Interface for FSRegistry Instance.
- """
-
- def testInterfaceVerification(self):
- verifyObject(IGlobalFSSyncUtility, fsRegistry)
-
- def testFSRegistry(self):
- """ Test Class and Factory registration and getSynchronizer to get
- appropriate factory for that class.
- """
- self.assertRaises(FactoryNotFoundError, getSynchronizer, C1())
-
- provideSynchronizer(C1, CFileAdapter)
- cl = C1()
- fac = getSynchronizer(cl)
- self.assertEqual(fac.__class__, CFileAdapter)
- self.assertEqual(fac.getBody(), C1.__doc__)
-
- provideSynchronizer(C2, CDirAdapter)
- fac = getSynchronizer(C2())
- self.assertEqual(fac.__class__, CDirAdapter)
- self.assertEqual(fac.contents(), [])
-
- def testFSRegitryDefaultFactory(self):
- """Test for default Factory
- """
- provideSynchronizer(None, CDefaultAdapter)
- fac = getSynchronizer(C1())
- self.assertEqual(fac.__class__, CDefaultAdapter)
-
- fac = getSynchronizer(C2())
- self.assertEqual(fac.__class__, CDefaultAdapter)
-
- def testFSRegDuplication(self):
- """Test for duplication in registring the same class in
- to the Registry.
- """
- provideSynchronizer(C2, CFileAdapter)
- #Try to change the adapter for same class should
- #throw a duplication error
- self.assertRaises(DuplicationError,
- provideSynchronizer, C2, CDirAdapter)
-
-def test_suite():
- return TestSuite((makeSuite(Test),))
-
-if __name__=='__main__':
- main(defaultTest='test_suite')
Added: Zope3/trunk/src/zope/app/fssync/tests/test_registration.py
===================================================================
--- Zope3/trunk/src/zope/app/fssync/tests/test_registration.py 2007-02-08 06:51:24 UTC (rev 72446)
+++ Zope3/trunk/src/zope/app/fssync/tests/test_registration.py 2007-02-08 07:48:58 UTC (rev 72447)
@@ -0,0 +1,34 @@
+##############################################################################
+#
+# Copyright (c) 2003 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (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.
+#
+##############################################################################
+"""Registration tests
+
+$Id: test_registration.py 40495 2005-12-02 17:51:22Z efge $
+"""
+import unittest
+from zope.testing import doctest, module
+
+def setUp(test):
+ module.setUp(test, 'zope.app.fssync.registration_txt')
+
+def tearDown(test):
+ module.tearDown(test, 'zope.app.fssync.registration_txt')
+
+def test_suite():
+ return unittest.TestSuite((
+ doctest.DocFileSuite('../registration.txt',
+ setUp=setUp, tearDown=tearDown,
+ optionflags=doctest.NORMALIZE_WHITESPACE+doctest.ELLIPSIS),
+ ))
+
+if __name__ == '__main__': unittest.main()
Deleted: Zope3/trunk/src/zope/app/fssync/zope.app.fssync-meta.zcml
===================================================================
--- Zope3/trunk/src/zope/app/fssync/zope.app.fssync-meta.zcml 2007-02-08 06:51:24 UTC (rev 72446)
+++ Zope3/trunk/src/zope/app/fssync/zope.app.fssync-meta.zcml 2007-02-08 07:48:58 UTC (rev 72447)
@@ -1 +0,0 @@
-<include package="zope.app.fssync" file="meta.zcml" />
Modified: Zope3/trunk/src/zope/app/module/fssync/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/module/fssync/configure.zcml 2007-02-08 06:51:24 UTC (rev 72446)
+++ Zope3/trunk/src/zope/app/module/fssync/configure.zcml 2007-02-08 07:48:58 UTC (rev 72447)
@@ -1,11 +1,12 @@
<configure
xmlns="http://namespaces.zope.org/zope"
- xmlns:fssync="http://namespaces.zope.org/fssync"
>
- <fssync:adapter
- class="zope.app.module.manager.ModuleManager"
- factory=".adapter.ModuleAdapter"
+ <utility
+ component=".adapter.ModuleAdapter"
+ name="zope.app.module.manager.ModuleManager"
+ provides="zope.app.fssync.interfaces.IFSSyncFactory"
+ permission="zope.ManageCode"
/>
</configure>
Modified: Zope3/trunk/src/zope/app/zptpage/fssync/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/zptpage/fssync/configure.zcml 2007-02-08 06:51:24 UTC (rev 72446)
+++ Zope3/trunk/src/zope/app/zptpage/fssync/configure.zcml 2007-02-08 07:48:58 UTC (rev 72447)
@@ -1,12 +1,13 @@
<configure
xmlns='http://namespaces.zope.org/zope'
- xmlns:fssync='http://namespaces.zope.org/fssync'
i18n_domain='zope'
>
- <fssync:adapter
- class="zope.app.zptpage.ZPTPage"
- factory=".adapter.ZPTPageAdapter"
+ <utility
+ component=".adapter.ZPTPageAdapter"
+ name="zope.app.zptpage.ZPTPage"
+ provides="zope.app.fssync.interfaces.IFSSyncFactory"
+ permission="zope.ManageContent"
/>
</configure>
Modified: Zope3/trunk/src/zope/dublincore/fssync/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/dublincore/fssync/configure.zcml 2007-02-08 06:51:24 UTC (rev 72446)
+++ Zope3/trunk/src/zope/dublincore/fssync/configure.zcml 2007-02-08 07:48:58 UTC (rev 72447)
@@ -1,18 +1,10 @@
<configure
- xmlns="http://namespaces.zope.org/zope"
- xmlns:fssync="http://namespaces.zope.org/fssync">
-
- <!-- Do we need the fssync:adapter statement at all?
- <fssync:adapter
- class="zope.dublincore.annotatableadapter.ZDCAnnotationData"
- factory=".adapter.ZDCAnnotationDataAdapter"
- />
- -->
-
- <adapter
- for="zope.dublincore.annotatableadapter.ZDCAnnotationData"
- factory=".adapter.ZDCAnnotationDataAdapter"
- trusted="true"
+ xmlns="http://namespaces.zope.org/zope">
+
+ <utility
+ component=".adapter.ZDCAnnotationDataAdapter"
+ name="zope.dublincore.annotatableadapter.ZDCAnnotationData"
+ provides="zope.app.fssync.interfaces.IFSSyncFactory"
permission="zope.ManageContent"
/>
More information about the Checkins
mailing list