Mailing List Archive

SVN: PluginRegistry/trunk/ Moved interfaces into a top-level module (no need for a package), and made them forward-compatible with Z3 interfaces.
Log message for revision 40099:
Moved interfaces into a top-level module (no need for a package), and made them forward-compatible with Z3 interfaces.



Changed:
U PluginRegistry/trunk/CHANGES.txt
U PluginRegistry/trunk/PluginRegistry.py
U PluginRegistry/trunk/exportimport.py
D PluginRegistry/trunk/interfaces/
A PluginRegistry/trunk/interfaces/
A PluginRegistry/trunk/interfaces.py
U PluginRegistry/trunk/tests/test_PluginRegistry.py

-=-
Modified: PluginRegistry/trunk/CHANGES.txt
===================================================================
--- PluginRegistry/trunk/CHANGES.txt 2005-11-14 19:14:00 UTC (rev 40098)
+++ PluginRegistry/trunk/CHANGES.txt 2005-11-14 20:48:24 UTC (rev 40099)
@@ -4,6 +4,9 @@

- SVN tag: svn+ssh://svn.zope.org/repos/main/PluginRegistry/trunk

+ - Moved interfaces into a top-level module (no need for a package),
+ and made them forward-compatible with Z3 interfaces.
+
- Wired in DAV / FTP / ExternalEditor support for the registry,
along with a ZMI form for updating it as XML.


Modified: PluginRegistry/trunk/PluginRegistry.py
===================================================================
--- PluginRegistry/trunk/PluginRegistry.py 2005-11-14 19:14:00 UTC (rev 40098)
+++ PluginRegistry/trunk/PluginRegistry.py 2005-11-14 20:48:24 UTC (rev 40099)
@@ -25,12 +25,29 @@
from Persistence import PersistentMapping
from OFS.SimpleItem import SimpleItem
from App.class_init import default__class_init__ as InitializeClass
-from webdav.WriteLockInterface import WriteLockInterface
+
+try:
+ from webdav.interfaces import IWriteLock
+except ImportError:
+ try:
+ from Products.Five.interfaces import IWriteLock
+ except ImportError:
+ _HAS_Z3_DAV_INTERFACES = False
+ from webdav.WriteLockInterface import WriteLockInterface
+ else:
+ _HAS_Z3_DAV_INTERFACES = True
+else:
+ _HAS_Z3_DAV_INTERFACES = True
+
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from Products.PageTemplates.Expressions import getEngine
from Products.PageTemplates.Expressions import SecureModuleImporter

-from interfaces.plugins import IPluginRegistry
+from interfaces import IPluginRegistry
+from interfaces import _HAS_Z3_INTERFACES
+if _HAS_Z3_INTERFACES:
+ from zope.interface import implements
+
try:
from exportimport import _updatePluginRegistry
except ImportError:
@@ -46,7 +63,14 @@

o Each plugin type holds an ordered list of ( id, wrapper ) tuples.
"""
- __implements__ = ( IPluginRegistry, WriteLockInterface )
+ if _HAS_Z3_INTERFACES:
+ if _HAS_Z3_DAV_INTERFACES:
+ implements(IPluginRegistry, IWriteLock)
+ else:
+ implements(IPluginRegistry)
+ __implements__ = (WriteLockInterface,)
+ else:
+ __implements__ = (IPluginRegistry, WriteLockInterface,)

security = ClassSecurityInfo()


Modified: PluginRegistry/trunk/exportimport.py
===================================================================
--- PluginRegistry/trunk/exportimport.py 2005-11-14 19:14:00 UTC (rev 40098)
+++ PluginRegistry/trunk/exportimport.py 2005-11-14 20:48:24 UTC (rev 40099)
@@ -16,8 +16,15 @@

$Id$
"""
+from StringIO import StringIO
+
from Persistence import PersistentMapping
+from zope.interface import implements

+from Products.GenericSetup.interfaces import IFilesystemExporter
+from Products.GenericSetup.interfaces import IFilesystemImporter
+from Products.GenericSetup.content import FauxDAVRequest
+from Products.GenericSetup.content import FauxDAVResponse
from Products.GenericSetup.utils import ExportConfiguratorBase
from Products.GenericSetup.utils import ImportConfiguratorBase
from Products.GenericSetup.utils import _getDottedName
@@ -27,7 +34,7 @@
from Products.GenericSetup.utils import KEY
from Products.PageTemplates.PageTemplateFile import PageTemplateFile

-from interfaces.plugins import IPluginRegistry
+from interfaces import IPluginRegistry

def _providedBy(obj, iface):
try:
@@ -51,6 +58,8 @@

def exportPluginRegistry(context):
""" Export plugin registry as an XML file.
+
+ o Designed for use as a GenericSetup export step.
"""
registry = _getRegistry(context.getSite())
pre = PluginRegistryExporter(registry).__of__(registry)
@@ -81,6 +90,8 @@

def importPluginRegistry(context):
""" Import plugin registry from an XML file.
+
+ o Designed for use as a GenericSetup import step.
"""
registry = _getRegistry(context.getSite())
encoding = context.getEncoding()
@@ -132,3 +143,44 @@
{'id': {KEY: 'id'},
},
}
+
+class PluginRegistryFileExportImportAdapter(object):
+ """ Designed for ues when exporting / importing PR's within a container.
+ """
+ implements(IFilesystemExporter, IFilesystemImporter)
+
+ def __init__(self, context):
+ self.context = context
+
+ def export(self, export_context, subdir, root=False):
+ """ See IFilesystemExporter.
+ """
+ context = self.context
+ pre = PluginRegistryExporter(context).__of__(context)
+ xml = pre.generateXML()
+ export_context.writeDataFile(_FILENAME,
+ xml,
+ 'text/xml',
+ subdir,
+ )
+
+ def listExportableItems(self):
+ """ See IFilesystemExporter.
+ """
+ return ()
+
+ def import_(self, import_context, subdir, root=False):
+ """ See IFilesystemImporter.
+ """
+ data = import_context.readDataFile(_FILENAME, subdir)
+ if data is None:
+ import_context.note('SGAIFA',
+ 'no pluginregistry.xml in %s' % subdir)
+ else:
+ request = FauxDAVRequest(BODY=data, BODYFILE=StringIO(data))
+ response = FauxDAVResponse()
+ _updatePluginRegistry(self.context,
+ data,
+ import_context.shouldPurge(),
+ import_context.getEncoding(),
+ )

Added: PluginRegistry/trunk/interfaces.py
===================================================================
--- PluginRegistry/trunk/interfaces.py 2005-11-14 19:14:00 UTC (rev 40098)
+++ PluginRegistry/trunk/interfaces.py 2005-11-14 20:48:24 UTC (rev 40099)
@@ -0,0 +1,113 @@
+##############################################################################
+#
+# Copyright (c) 2001 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
+#
+##############################################################################
+""" PluginRegistry interface declarations
+
+$Id$
+"""
+try:
+ from zope.interface import Interface
+except: # BBB?
+ from Interface import Interface
+ _HAS_Z3_INTERFACES = False
+else:
+ _HAS_Z3_INTERFACES = True
+
+class IPluginRegistry( Interface ):
+
+
+ """ Manage a set of plugin definitions, grouped by type.
+ """
+ def listPluginTypeInfo():
+
+ """ Return a sequence of mappings describing our plugin types.
+
+ o Keys for the mappings must include:
+
+ 'id' -- a string used to identify the plugin type (should be
+ the __name__ of the interface)
+
+ 'interface' -- the plugin type interface
+
+ 'methods' -- the methods expected by the plugin type interface
+
+ 'title' -- a display title for the plugin type
+
+ 'description' -- a description of what the plugins do
+ """
+
+ def listPlugins( plugin_type ):
+
+ """ Return a sequence of tuples, one for each plugin of the given type.
+
+ o 'plugin_type' must be one of the known types, else raise KeyError.
+
+ o Tuples will be of the form, '( plugin_id, plugin )'.
+ """
+
+ def listPluginIds( plugin_type ):
+
+ """ Return a sequence of plugin ids
+
+ o Return ids for each active plugin of the given type.
+
+ o 'plugin_type' must be one of the known types, else raise KeyError.
+ """
+
+ def activatePlugin( plugin_type, plugin_id ):
+
+ """ Activate a plugin of the given type.
+
+ o 'plugin_type' must be one of the known types, else raise KeyError.
+
+ o 'plugin_id' must be the ID of an available plugin, else raise
+ KeyError.
+
+ o Append 'plugin_id' to the list of active plugins for the given
+ 'plugin_type'.
+ """
+
+ def deactivatePlugin( plugin_type, plugin_id ):
+
+ """ Deactivate a plugin of the given type.
+
+ o 'plugin_type' must be one of the known types, else raise KeyError.
+
+ o 'plugin_id' must be an ID of an existing plugin of that type,
+ else raise KeyError.
+ """
+
+ def movePluginsUp( plugin_type, ids_to_move ):
+
+ """ Move a set of plugins "up" in their list.
+
+ o 'plugin_type' must be one of the known types, else raise KeyError.
+
+ o 'ids_to_move' must be a sequence of ids of current plugins
+ for that type.
+
+ - If any item is not the ID of a current plugin, raise ValueError.
+ """
+
+ def movePluginsDown( plugin_type, ids_to_move ):
+
+ """ Move a set of plugins "down" in their list.
+
+ o 'plugin_type' must be one of the known types, else raise KeyError.
+
+ o 'ids_to_move' must be a sequence of indexes of items in the current
+ list of plugins for that type.
+
+ - If any item is not the ID of a current plugin, raise ValueError.
+ """


Property changes on: PluginRegistry/trunk/interfaces.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native

Modified: PluginRegistry/trunk/tests/test_PluginRegistry.py
===================================================================
--- PluginRegistry/trunk/tests/test_PluginRegistry.py 2005-11-14 19:14:00 UTC (rev 40098)
+++ PluginRegistry/trunk/tests/test_PluginRegistry.py 2005-11-14 20:48:24 UTC (rev 40099)
@@ -57,12 +57,15 @@

return self._getTargetClass()( plugin_info, *args, **kw )

- def test_conformance_IPluginRegistry( self ):
+ def test_conformance_to_IPluginRegistry( self ):

- from Products.PluginRegistry.interfaces.plugins \
- import IPluginRegistry
+ from Products.PluginRegistry.interfaces import IPluginRegistry
+ from Products.PluginRegistry.interfaces import _HAS_Z3_INTERFACES

- from Interface.Verify import verifyClass
+ if _HAS_Z3_INTERFACES:
+ from zope.interface.verify import verifyClass
+ else:
+ from Interface.Verify import verifyClass

verifyClass( IPluginRegistry, self._getTargetClass() )


_______________________________________________
Zope-CVS maillist - Zope-CVS@zope.org
http://mail.zope.org/mailman/listinfo/zope-cvs

Zope CVS instructions: http://dev.zope.org/CVS