[CMF-checkins] CVS: CMF/CMFSetup - actions.py:1.2 rolemap.py:1.7 utils.py:1.4

Tres Seaver tseaver at zope.com
Tue May 25 00:13:05 EDT 2004


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

Modified Files:
	actions.py rolemap.py utils.py 
Log Message:
 - Preliminary cut at skins tool import / export.


=== CMF/CMFSetup/actions.py 1.1 => 1.2 ===
--- CMF/CMFSetup/actions.py:1.1	Mon May 24 18:43:50 2004
+++ CMF/CMFSetup/actions.py	Tue May 25 00:12:33 2004
@@ -3,7 +3,6 @@
 $Id$
 """
 from xml.sax import parseString
-from xml.sax.handler import ContentHandler
 
 from AccessControl import ClassSecurityInfo
 from Acquisition import Implicit
@@ -13,14 +12,17 @@
 from Products.CMFCore.utils import getToolByName
 
 from permissions import ManagePortal
+from utils import HandlerBase
 from utils import _xmldir
 
-# Dummy object for passing to listActions
 class _FauxContent:
+
+    # Dummy object for passing to listActions
+
     def __init__( self, **kw ):
         self.__dict__.update( kw )
 
-class _ActionProviderParser( ContentHandler ):
+class _ActionProviderParser( HandlerBase ):
 
     def __init__( self, site, encoding='latin-1' ):
 
@@ -29,10 +31,6 @@
         self._provider_info = {}
         self._provider_ids = []
 
-    def _extract( self, attrs, key ):
-
-        return attrs[ key ].encode( self._encoding )
-
     def startElement( self, name, attrs ):
 
         if name == 'actions-tool':
@@ -179,13 +177,13 @@
 
 def importActionProviders( context ):
 
-    """ Export roles / permission map as an XML file
+    """ Import roles / permission map from an XML file
 
     o 'context' must implement IImportContext.
 
     o Register via Python:
 
-      registry = site.portal_setup.setup_steps
+      registry = site.portal_setup.getImportStepRegistry()
       registry.registerStep( 'importActionProviders'
                            , '20040518-01'
                            , Products.CMFSetup.actions.importActionProviders
@@ -231,9 +229,9 @@
 
     o Register via Python:
 
-      registry = site.portal_setup.export_steps
+      registry = site.portal_setup.getExportStepRegistry()
       registry.registerStep( 'exportActionProviders'
-                           , Products.CMFSetup.rolemap.exportActionProviders
+                           , Products.CMFSetup.actions.exportActionProviders
                            , 'Action Provider export'
                            , 'Export action providers registered with '
                              'the actions tool, and their actions.'
@@ -243,7 +241,7 @@
  
       <export-script id="exportActionProviders"
                      version="20040518-01"
-                     handler="Products.CMFSetup.rolemap.exportActionProviders"
+                     handler="Products.CMFSetup.actions.exportActionProviders"
                      title="Action Provider export"
       >Export action providers registered with the actions tool,
        and their actions.</export-script>


=== CMF/CMFSetup/rolemap.py 1.6 => 1.7 ===
--- CMF/CMFSetup/rolemap.py:1.6	Mon May 24 18:43:50 2004
+++ CMF/CMFSetup/rolemap.py	Tue May 25 00:12:33 2004
@@ -3,7 +3,6 @@
 $Id$
 """
 from xml.sax import parseString
-from xml.sax.handler import ContentHandler
 
 from AccessControl import ClassSecurityInfo
 from AccessControl.Permission import Permission
@@ -12,9 +11,10 @@
 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
 
 from permissions import ManagePortal
+from utils import HandlerBase
 from utils import _xmldir
 
-class _RolemapParser( ContentHandler ):
+class _RolemapParser( HandlerBase ):
 
     def __init__( self, site, encoding='latin-1' ):
 
@@ -26,14 +26,18 @@
     def startElement( self, name, attrs ):
 
         if name == 'role':
-            self._roles.append( attrs[ 'name' ].encode( self._encoding )  )
+            self._roles.append( self._extract( attrs, 'name' )  )
 
         elif name == 'permission':
-            p_name = attrs[ 'name' ].encode( self._encoding )
-            roles = attrs[ 'roles' ].encode( self._encoding ).split()
-            acquire = attrs[ 'acquire' ].encode( self._encoding ).lower()
+
+            acquire = self._extract( attrs, 'acquire' ).lower()
             acquire = acquire in ( '1', 'true', 'yes' )
-            info = { 'name' : p_name, 'roles' : roles, 'acquire' : acquire }
+
+            info = { 'name'     : self._extract( attrs, 'name' )
+                   , 'roles'    : self._extract( attrs, 'roles' ).split()
+                   , 'acquire'  : acquire
+                   }
+
             self._permissions.append( info )
 
         elif name not in ( 'rolemap', 'permissions', 'roles' ):


=== CMF/CMFSetup/utils.py 1.3 => 1.4 ===
--- CMF/CMFSetup/utils.py:1.3	Fri May 14 09:22:43 2004
+++ CMF/CMFSetup/utils.py	Tue May 25 00:12:33 2004
@@ -5,6 +5,7 @@
 import os
 from inspect import getdoc
 from types import StringTypes, InstanceType
+from xml.sax.handler import ContentHandler
 
 from Globals import package_home
 
@@ -73,3 +74,10 @@
         description = '\n'.join( lines[ 1: ] )
 
     return title, description
+
+class HandlerBase( ContentHandler ):
+
+    def _extract( self, attrs, key ):
+
+        return attrs[ key ].encode( self._encoding )
+




More information about the CMF-checkins mailing list