[CMF-checkins] CVS: CMF/CMFSetup - registry.py:1.6 utils.py:1.3
Tres Seaver
tseaver at zope.com
Fri May 14 09:23:14 EDT 2004
Update of /cvs-repository/CMF/CMFSetup
In directory cvs.zope.org:/tmp/cvs-serv9455
Modified Files:
registry.py utils.py
Log Message:
- registry.py:
o Store the dotted names of handlers, compute the resolved versions
(preliminary for making registries persistent).
- utils.py:
o Make _getDottedName more robust w.r.t. passed values; add tests.
=== CMF/CMFSetup/registry.py 1.5 => 1.6 ===
--- CMF/CMFSetup/registry.py:1.5 Fri May 14 08:45:29 2004
+++ CMF/CMFSetup/registry.py Fri May 14 09:22:43 2004
@@ -3,6 +3,7 @@
$Id$
"""
import re
+from types import StringTypes
from xml.sax import parseString
from xml.sax.handler import ContentHandler
@@ -102,14 +103,7 @@
if info is None:
return default
- for key, value in info.items():
-
- if key == 'handler':
- result[ key ] = _getDottedName( value )
- else:
- result[ key ] = value
-
- return result
+ return info.copy()
security.declareProtected( ManagePortal, 'listStepMetadata' )
def listStepMetadata( self ):
@@ -144,7 +138,7 @@
if info is marker:
return default
- return info[ 'handler' ]
+ return _resolveDottedName( info[ 'handler' ] )
security.declarePrivate( 'registerStep' )
def registerStep( self
@@ -197,9 +191,12 @@
title = title or t
description = description or d
+ if type( handler ) not in StringTypes:
+ handler = _getDottedName( handler )
+
info = { 'id' : id
, 'version' : version
- , 'handler' : handler
+ , 'handler' : handler
, 'dependencies' : dependencies
, 'title' : title
, 'description' : description
@@ -390,21 +387,12 @@
o The 'handler' metadata is available via 'getScript'.
"""
- result = {}
-
info = self._registered.get( key )
if info is None:
return default
- for key, value in info.items():
-
- if key == 'handler':
- result[ key ] = _getDottedName( value )
- else:
- result[ key ] = value
-
- return result
+ return info.copy()
security.declareProtected( ManagePortal, 'listScriptMetadata' )
def listScriptMetadata( self ):
@@ -439,7 +427,7 @@
if info is marker:
return default
- return info[ 'handler' ]
+ return _resolveDottedName( info[ 'handler' ] )
security.declarePrivate( 'registerScript' )
def registerScript( self, id, handler, title=None, description=None ):
@@ -470,8 +458,11 @@
title = title or t
description = description or d
+ if type( handler ) not in StringTypes:
+ handler = _getDottedName( handler )
+
info = { 'id' : id
- , 'handler' : handler
+ , 'handler' : handler
, 'title' : title
, 'description' : description
}
=== CMF/CMFSetup/utils.py 1.2 => 1.3 ===
--- CMF/CMFSetup/utils.py:1.2 Tue May 11 23:09:22 2004
+++ CMF/CMFSetup/utils.py Fri May 14 09:22:43 2004
@@ -4,6 +4,7 @@
"""
import os
from inspect import getdoc
+from types import StringTypes, InstanceType
from Globals import package_home
@@ -12,9 +13,15 @@
_datadir = os.path.join( _pkgdir, 'data' )
_xmldir = os.path.join( _pkgdir, 'xml' )
-def _getDottedName( callable ):
+def _getDottedName( named ):
- return '%s.%s' % ( callable.__module__, callable.__name__ )
+ if isinstance( named, StringTypes ):
+ return str( named )
+
+ try:
+ return '%s.%s' % ( named.__module__, named.__name__ )
+ except AttributeError:
+ raise ValueError, 'Cannot compute dotted name: %s' % named
def _resolveDottedName( dotted ):
More information about the CMF-checkins
mailing list