[Zope3-checkins]
SVN: Zope3/branches/srichter-blow-services/src/zope/app/
Started cleaning up the persistent module code. Much more
work has to be
Stephan Richter
srichter at cosmos.phy.tufts.edu
Thu Jan 6 19:10:21 EST 2005
Log message for revision 28756:
Started cleaning up the persistent module code. Much more work has to be
done on it though.
Changed:
U Zope3/branches/srichter-blow-services/src/zope/app/introspector/__init__.py
U Zope3/branches/srichter-blow-services/src/zope/app/module/__init__.py
U Zope3/branches/srichter-blow-services/src/zope/app/module/interfaces.py
-=-
Modified: Zope3/branches/srichter-blow-services/src/zope/app/introspector/__init__.py
===================================================================
--- Zope3/branches/srichter-blow-services/src/zope/app/introspector/__init__.py 2005-01-07 00:08:38 UTC (rev 28755)
+++ Zope3/branches/srichter-blow-services/src/zope/app/introspector/__init__.py 2005-01-07 00:10:21 UTC (rev 28756)
@@ -19,7 +19,6 @@
from zope.interface import Interface
from zope.app.introspector.interfaces import IIntrospector
-from zope.app.module.interfaces import IModuleService
from zope.component import getService, getServiceDefinitions, getServices
from zope.interface import implements, implementedBy
from zope.interface import directlyProvides, directlyProvidedBy, providedBy
Modified: Zope3/branches/srichter-blow-services/src/zope/app/module/__init__.py
===================================================================
--- Zope3/branches/srichter-blow-services/src/zope/app/module/__init__.py 2005-01-07 00:08:38 UTC (rev 28755)
+++ Zope3/branches/srichter-blow-services/src/zope/app/module/__init__.py 2005-01-07 00:10:21 UTC (rev 28756)
@@ -16,12 +16,14 @@
$Id$
"""
__docformat__ = 'restructuredtext'
-
+import sys
from persistent import Persistent
from zodbcode.module import PersistentModule, compileModule
+
from zope.interface import implements
from zope.security.proxy import removeSecurityProxy
+from zope.app import zapi
from zope.app.annotation.interfaces import IAttributeAnnotatable
from zope.app.filerepresentation.interfaces import IFileFactory
from zope.app.module.interfaces import IModuleManager
@@ -82,11 +84,6 @@
source = property(_get_source, _set_source)
-# Hack to allow unpickling of old Managers to get far enough for __setstate__
-# to do it's magic:
-Registry = Manager
-
-
class ModuleFactory(object):
implements(IFileFactory)
@@ -109,3 +106,17 @@
def installPersistentModuleImporter(event):
from zodbcode.module import PersistentModuleImporter
PersistentModuleImporter().install()
+
+
+def findModule(name, context=None):
+ util = zapi.queryUtility(IModuleManager, name, context=context)
+ if util is not None:
+ return util.getModule()
+ return sys.modules.get(name)
+
+
+def resolve(name, context=None):
+ pos = name.rfind('.')
+ mod = findModule(name[:pos], context)
+ return getattr(mod, name[pos+1:])
+
Modified: Zope3/branches/srichter-blow-services/src/zope/app/module/interfaces.py
===================================================================
--- Zope3/branches/srichter-blow-services/src/zope/app/module/interfaces.py 2005-01-07 00:08:38 UTC (rev 28755)
+++ Zope3/branches/srichter-blow-services/src/zope/app/module/interfaces.py 2005-01-07 00:10:21 UTC (rev 28756)
@@ -11,11 +11,8 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""Interfaces needed by the module service.
+"""Interfaces needed for the persistent module framework.
-TODO: There is no module service yet; instead, the service manager
-currently implements it. This should change.
-
$Id$
"""
__docformat__ = 'restructuredtext'
@@ -43,16 +40,3 @@
source = ASCII(title=u"The module's source code.")
-
-class IModuleService(Interface):
- """Objects that can resolve dotted names to objects
- """
-
- def resolve(dotted_name):
- """Resolve the given dotted name to a module global variable.
-
- If the name ends with a trailing dot, the last name segment
- may be repeated.
-
- If the dotted name cannot be resolved, an ``ImportError`` is raised.
- """
More information about the Zope3-Checkins
mailing list