[CMF-checkins] CVS: CMF/CMFSetup - z2interfaces.py:1.1.2.1 actions.py:1.21.6.1 context.py:1.16.8.1 interfaces.py:1.20.6.1 registry.py:1.20.6.1 tool.py:1.23.6.1

Tres Seaver tseaver at palladion.com
Fri Jul 15 18:41:53 EDT 2005


Update of /cvs-repository/CMF/CMFSetup
In directory cvs.zope.org:/tmp/cvs-serv16776/CMFSetup

Modified Files:
      Tag: tseaver-z3_interfaces-branch
	actions.py context.py interfaces.py registry.py tool.py 
Added Files:
      Tag: tseaver-z3_interfaces-branch
	z2interfaces.py 
Log Message:


Branch for Z3-ification of CMF interfaces

 - All interfaces declared in the CMF are now Zope3-style interfaces
   (the one remaining exception is to leave Zope2's
   'webdav.WriteLockInterface' declared by CMFCore.PortalContent and
   derivatives.).

TOOD

  - Clean up XXX'es noted during this pass.


=== Added File CMF/CMFSetup/z2interfaces.py ===
##############################################################################
#
# Copyright (c) 2004 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.
#
##############################################################################
""" CMFSetup product interfaces

$Id: z2interfaces.py,v 1.1.2.1 2005/07/15 22:41:22 tseaver Exp $
"""

from Interface import Interface


BASE, EXTENSION = range(2)


class IPseudoInterface( Interface ):

    """ API documentation;  not testable / enforceable.
    """

class ISetupContext( Interface ):

    """ Context used for export / import plugins.
    """
    def getSite():

        """ Return the site object being configured / dumped.
        """

class IImportContext( ISetupContext ):

    def getEncoding():

        """ Get the encoding used for configuration data within the site.

        o Return None if the data should not be encoded.
        """

    def readDataFile( filename, subdir=None ):

        """ Search the current configuration for the requested file.

        o 'filename' is the name (without path elements) of the file.

        o 'subdir' is an optional subdirectory;  if not supplied, search
          only the "root" directory.

        o Return the file contents as a string, or None if the
          file cannot be found.
        """

    def getLastModified( path ):

        """ Return the modification timestamp of the item at 'path'.

        o Result will be a DateTime instance.

        o Search profiles in the configuration in order.

        o If the context is filesystem based, return the 'stat' timestamp
          of the file / directory to which 'path' points.

        o If the context is ZODB-based, return the Zope modification time
          of the object to which 'path' points.

        o Return None if 'path' does not point to any object.
        """

    def isDirectory( path ):

        """ Test whether path points to a directory / folder.

        o If the context is filesystem based, check that 'path' points to
          a subdirectory within the "root" directory.

        o If the context is ZODB-based, check that 'path' points to a
          "container" under the context's tool.

        o Return None if 'path' does not resolve;  otherwise, return a
          bool.
        """

    def listDirectory( path, skip=('CVS',) ):

        """ List IDs of the contents of a  directory / folder.

        o Omit names in 'skip'.

        o If 'path' does not point to a directory / folder, return None.
        """

    def shouldPurge():

        """ When installing, should the existing setup be purged?
        """

class IImportPlugin( IPseudoInterface ):

    """ Signature for callables used to import portions of site configuration.
    """
    def __call__( context ):

        """ Perform the setup step.

        o Return a message describing the work done.

        o 'context' must implement IImportContext.
        """

class IExportContext( ISetupContext ):

    def writeDataFile( filename, text, content_type, subdir=None ):

        """ Write data into the specified location.

        o 'filename' is the unqualified name of the file.

        o 'text' is the content of the file.

        o 'content_type' is the MIMEtype of the file.

        o 'subdir', if passed, is a path to a subdirectory / folder in
          which to write the file;  if not passed, write the file to the
          "root" of the target.
        """

class IExportPlugin( IPseudoInterface ):

    """ Signature for callables used to export portions of site configuration.
    """
    def __call__( context ):

        """ Write export data for the site wrapped by context.

        o Return a message describing the work done.

        o 'context' must implement IExportContext.  The plugin will use
          its 'writeDataFile' method for each file to be exported.
        """

class IStepRegistry( Interface ):

    """ Base interface for step registries.
    """
    def listSteps():

        """ Return a sequence of IDs of registered steps.

        o Order is not significant.
        """

    def listStepMetadata():

        """ Return a sequence of mappings describing registered steps.

        o Mappings will be ordered alphabetically.
        """

    def getStepMetadata( key, default=None ):

        """ Return a mapping of metadata for the step identified by 'key'.

        o Return 'default' if no such step is registered.

        o The 'handler' metadata is available via 'getStep'.
        """

    def generateXML():

        """ Return a round-trippable XML representation of the registry.

        o 'handler' values are serialized using their dotted names.
        """

    def parseXML( text ):

        """ Parse 'text'.
        """

class IImportStepRegistry( IStepRegistry ):

    """ API for import step registry.
    """
    def sortSteps():

        """ Return a sequence of registered step IDs

        o Sequence is sorted topologically by dependency, with the dependent
          steps *after* the steps they depend on.
        """

    def checkComplete():

        """ Return a sequence of ( node, edge ) tuples for unsatisifed deps.
        """

    def getStep( key, default=None ):

        """ Return the IImportPlugin registered for 'key'.

        o Return 'default' if no such step is registered.
        """

    def registerStep( id
                    , version
                    , handler
                    , dependencies=()
                    , title=None
                    , description=None
                    ):
        """ Register a setup step.

        o 'id' is a unique name for this step,

        o 'version' is a string for comparing versions, it is preferred to
          be a yyyy/mm/dd-ii formatted string (date plus two-digit
          ordinal).  when comparing two version strings, the version with
          the lower sort order is considered the older version.

          - Newer versions of a step supplant older ones.

          - Attempting to register an older one after a newer one results
            in a KeyError.

        o 'handler' should implement IImportPlugin.

        o 'dependencies' is a tuple of step ids which have to run before
          this step in order to be able to run at all. Registration of
          steps that have unmet dependencies are deferred until the
          dependencies have been registered.

        o 'title' is a one-line UI description for this step.
          If None, the first line of the documentation string of the handler
          is used, or the id if no docstring can be found.

        o 'description' is a one-line UI description for this step.
          If None, the remaining line of the documentation string of
          the handler is used, or default to ''.
        """

class IExportStepRegistry( IStepRegistry ):

    """ API for export step registry.
    """
    def getStep( key, default=None ):

        """ Return the IExportPlugin registered for 'key'.

        o Return 'default' if no such step is registered.
        """

    def registerStep( id, handler, title=None, description=None ):

        """ Register an export step.

        o 'id' is the unique identifier for this step

        o 'handler' should implement IExportPlugin.

        o 'title' is a one-line UI description for this step.
          If None, the first line of the documentation string of the step
          is used, or the id if no docstring can be found.

        o 'description' is a one-line UI description for this step.
          If None, the remaining line of the documentation string of
          the step is used, or default to ''.
        """

class IToolsetRegistry( Interface ):

    """ API for toolset registry.
    """
    def listForbiddenTools():

        """ Return a list of IDs of tools which must be removed, if present.
        """

    def addForbiddenTool(tool_id ):

        """ Add 'tool_id' to the list of forbidden tools.

        o Raise KeyError if 'tool_id' is already in the list.

        o Raise ValueError if 'tool_id' is in the "required" list.
        """

    def listRequiredTools():

        """ Return a list of IDs of tools which must be present.
        """

    def getRequiredToolInfo( tool_id ):

        """ Return a mapping describing a partiuclar required tool.

        o Keys include:

          'id' -- the ID of the tool

          'class' -- a dotted path to its class

        o Raise KeyError if 'tool_id' id not a known tool.
        """

    def listRequiredToolInfo():

        """ Return a list of IDs of tools which must be present.
        """

    def addRequiredTool( tool_id, dotted_name ):

        """ Add a tool to our "required" list.

        o 'tool_id' is the tool's ID.

        o 'dotted_name' is a dotted (importable) name of the tool's class.

        o Raise KeyError if we have already registered a class for 'tool_id'.

        o Raise ValueError if 'tool_id' is in the "forbidden" list.
        """

class IProfileRegistry( Interface ):

    """ API for profile registry.
    """
    def getProfileInfo( profile_id ):

        """ Return a mapping describing a registered filesystem profile.

        o Keys include:

          'id' -- the ID of the profile

          'title' -- its title

          'description' -- a textual description of the profile

          'path' -- a path to the profile on the filesystem.

          'product' -- the name of the product to which 'path' is
             relative (None for absolute paths).

          'type' -- either BASE or EXTENSION
        """

    def listProfiles():

        """ Return a list of IDs for registered profiles.
        """

    def listProfileInfo():

        """ Return a list of mappings describing registered profiles.

        o See 'getProfileInfo' for a description of the mappings' keys.
        """

    def registerProfile( name
                       , title
                       , description
                       , path
                       , product=None
                       , profile_type=BASE
                       ):
        """ Add a new profile to the registry.

        o If an existing profile is already registered for 'product:name',
          raise KeyError.

        o If 'product' is passed, then 'path' should be interpreted as
          relative to the corresponding product directory.
        """

class ISetupTool( Interface ):

    """ API for SetupTool.
    """

    def getEncoding():

        """ Get the encoding used for configuration data within the site.

        o Return None if the data should not be encoded.
        """

    def getImportContextID():

        """ Get the ID of the active import context.
        """

    def setImportContext( context_id ):

        """ Set the ID of the active import context and update the registries.
        """

    def getImportStepRegistry():

        """ Return the IImportStepRegistry for the tool.
        """

    def getExportStepRegistry():

        """ Return the IExportStepRegistry for the tool.
        """

    def getToolsetRegistry():

        """ Return the IToolsetRegistry for the tool.
        """

    def runImportStep( step_id, run_dependencies=True, purge_old=None ):

        """ Execute a given setup step

        o 'step_id' is the ID of the step to run.

        o If 'purge_old' is True, then run the step after purging any
          "old" setup first (this is the responsibility of the step,
          which must check the context we supply).

        o If 'run_dependencies' is True, then run any out-of-date
          dependency steps first.

        o Return a mapping, with keys:

          'steps' -- a sequence of IDs of the steps run.

          'messages' -- a dictionary holding messages returned from each
            step
        """

    def runAllImportSteps( purge_old=None ):

        """ Run all setup steps in dependency order.

        o If 'purge_old' is True, then run each step after purging any
          "old" setup first (this is the responsibility of the step,
          which must check the context we supply).

        o Return a mapping, with keys:

          'steps' -- a sequence of IDs of the steps run.

          'messages' -- a dictionary holding messages returned from each
            step
        """

    def runExportStep( step_id ):

        """ Generate a tarball containing artifacts from one export step.

        o 'step_id' identifies the export step.

        o Return a mapping, with keys:

          'steps' -- a sequence of IDs of the steps run.

          'messages' -- a dictionary holding messages returned from each
            step

          'tarball' -- the stringified tar-gz data.
        """

    def runAllExportSteps():

        """ Generate a tarball containing artifacts from all export steps.

        o Return a mapping, with keys:

          'steps' -- a sequence of IDs of the steps run.

          'messages' -- a dictionary holding messages returned from each
            step

          'tarball' -- the stringified tar-gz data.
        """

    def createSnapshot( snapshot_id ):

        """ Create a snapshot folder using all steps.

        o 'snapshot_id' is the ID of the new folder.
        """

    def compareConfigurations( lhs_context
                             , rhs_context
                             , missing_as_empty=False
                             , ignore_whitespace=False
                             ):
        """ Compare two configurations.

        o 'lhs_context' and 'rhs_context' must implement IImportContext.

        o If 'missing_as_empty', then compare files not present as though
          they were zero-length;  otherwise, omit such files.

        o If 'ignore_whitespace', then suppress diffs due only to whitespace
          (c.f:  'diff -wbB')
        """


=== CMF/CMFSetup/actions.py 1.21 => 1.21.6.1 ===
--- CMF/CMFSetup/actions.py:1.21	Wed Apr 13 09:05:58 2005
+++ CMF/CMFSetup/actions.py	Fri Jul 15 18:41:22 2005
@@ -192,7 +192,7 @@
 
             provider = getToolByName( self._site, provider_id )
 
-            if not IActionProvider.isImplementedBy( provider ):
+            if not IActionProvider.providedBy( provider ):
                 continue
 
             if provider_id == 'portal_actions':


=== CMF/CMFSetup/context.py 1.16 => 1.16.8.1 ===
--- CMF/CMFSetup/context.py:1.16	Mon Jan 17 05:34:01 2005
+++ CMF/CMFSetup/context.py	Fri Jul 15 18:41:22 2005
@@ -37,6 +37,8 @@
 from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
 from Products.PythonScripts.PythonScript import PythonScript
 
+from zope.interface import implements, implementedBy
+
 from interfaces import IExportContext
 from interfaces import IImportContext
 from permissions import ManagePortal
@@ -44,7 +46,7 @@
 
 class DirectoryImportContext( Implicit ):
 
-    __implements__ = ( IImportContext, )
+    implements(IImportContext)
 
     security = ClassSecurityInfo()
 
@@ -146,7 +148,7 @@
 
 class DirectoryExportContext( Implicit ):
 
-    __implements__ = ( IExportContext, )
+    implements(IExportContext)
 
     security = ClassSecurityInfo()
 
@@ -188,7 +190,7 @@
 
 class TarballExportContext( Implicit ):
 
-    __implements__ = ( IExportContext, )
+    implements(IExportContext)
 
     security = ClassSecurityInfo()
 
@@ -245,7 +247,7 @@
 
 class SnapshotExportContext( Implicit ):
 
-    __implements__ = ( IExportContext, )
+    implements(IExportContext)
 
     security = ClassSecurityInfo()
 
@@ -344,7 +346,7 @@
 
 class SnapshotImportContext( Implicit ):
 
-    __implements__ = ( IImportContext, )
+    implements(IImportContext)
 
     security = ClassSecurityInfo()
 


=== CMF/CMFSetup/interfaces.py 1.20 => 1.20.6.1 ===
--- CMF/CMFSetup/interfaces.py:1.20	Sun Mar 20 16:19:47 2005
+++ CMF/CMFSetup/interfaces.py	Fri Jul 15 18:41:22 2005
@@ -15,7 +15,7 @@
 $Id$
 """
 
-from Interface import Interface
+from zope.interface import Interface
 
 
 BASE, EXTENSION = range(2)


=== CMF/CMFSetup/registry.py 1.20 => 1.20.6.1 ===
--- CMF/CMFSetup/registry.py:1.20	Sun Mar 20 16:19:47 2005
+++ CMF/CMFSetup/registry.py	Fri Jul 15 18:41:22 2005
@@ -22,6 +22,8 @@
 from Globals import InitializeClass
 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
 
+from zope.interface import implements, implementedBy
+
 from interfaces import BASE
 from interfaces import IImportStepRegistry
 from interfaces import IExportStepRegistry
@@ -41,7 +43,7 @@
 
     o Steps are composed together to define a site profile.
     """
-    __implements__ = ( IImportStepRegistry, )
+    implements(IImportStepRegistry)
 
     security = ClassSecurityInfo()
 
@@ -273,7 +275,7 @@
       - 'filename' is a suggested filename for use when downloading.
 
     """
-    __implements__ = ( IExportStepRegistry, )
+    implements(IExportStepRegistry)
 
     security = ClassSecurityInfo()
 
@@ -403,7 +405,7 @@
 
     """ Track required / forbidden tools.
     """
-    __implements__ = ( IToolsetRegistry, )
+    implements(IToolsetRegistry)
 
     security = ClassSecurityInfo()
     security.setDefaultAccess( 'allow' )
@@ -520,7 +522,7 @@
 
     """ Track registered profiles.
     """
-    __implements__ = ( IProfileRegistry, )
+    implements(IProfileRegistry)
 
     security = ClassSecurityInfo()
     security.setDefaultAccess( 'allow' )


=== CMF/CMFSetup/tool.py 1.23 => 1.23.6.1 ===
--- CMF/CMFSetup/tool.py:1.23	Mon Apr 11 07:33:17 2005
+++ CMF/CMFSetup/tool.py	Fri Jul 15 18:41:22 2005
@@ -25,6 +25,8 @@
 from OFS.Folder import Folder
 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
 
+from zope.interface import implements
+
 from Products.CMFCore.utils import UniqueObject
 from Products.CMFCore.utils import getToolByName
 
@@ -123,7 +125,8 @@
 
     """ Profile-based site configuration manager.
     """
-    __implements__ = ( ISetupTool, ) + Folder.__implements__
+    __implements__ = Folder.__implements__
+    implements(ISetupTool)
 
     id = 'portal_setup'
     meta_type = 'Portal Setup Tool'



More information about the CMF-checkins mailing list