[Zope3-checkins] CVS: Zope3/src/zope/modulealias - meta.zcml:1.1.2.2 metaconfigure.py:1.1.2.2 metadirectives.py:1.1.2.2

Chris McDonough chrism at plope.com
Wed Jan 14 11:46:41 EST 2004


Update of /cvs-repository/Zope3/src/zope/modulealias
In directory cvs.zope.org:/tmp/cvs-serv7425/modulealias

Modified Files:
      Tag: steveachrismcd-securitypolicy-branch
	meta.zcml metaconfigure.py metadirectives.py 
Log Message:
Write more tests, refactor, add importing functionality, rename schema elements.


=== Zope3/src/zope/modulealias/meta.zcml 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/modulealias/meta.zcml:1.1.2.1	Wed Jan 14 09:59:12 2004
+++ Zope3/src/zope/modulealias/meta.zcml	Wed Jan 14 11:46:10 2004
@@ -6,6 +6,6 @@
       namespace="http://namespaces.zope.org/zope"
       name="modulealias"
       schema=".metadirectives.IModuleAliasDirective"
-      handler=".metaconfigure.defineModuleAlias" />
+      handler=".metaconfigure.define_module_alias" />
 
 </configure>


=== Zope3/src/zope/modulealias/metaconfigure.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/modulealias/metaconfigure.py:1.1.2.1	Wed Jan 14 09:59:12 2004
+++ Zope3/src/zope/modulealias/metaconfigure.py	Wed Jan 14 11:46:10 2004
@@ -22,16 +22,23 @@
 
 import sys
 
-def defineModuleAlias(_context, source, target):
+class ModuleAliasException(Exception):
+    pass
+
+def define_module_alias(_context, module, alias):
     _context.action(
         discriminator = None,
-        callable = _defineModuleAlias,
-        args = (source, target),
+        callable = alias_module,
+        args = (module, alias, _context),
         )
 
-def _defineModuleAlias(source, target):
+def alias_module(module, alias, context):
     """ define a module alias by munging sys.modules """
-    if not sys.modules.has_key(source):
-        if sys.modules.has_key(target):
-            sys.modules[source] = sys.modules[target]
+    module_ob = context.resolve(module)
+    alias_ob = sys.modules.get(alias)
+
+    if alias_ob is not None and alias_ob is not module_ob: 
+        raise ModuleAliasException(module, alias)
+    
+    sys.modules[alias] = module_ob
 


=== Zope3/src/zope/modulealias/metadirectives.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/modulealias/metadirectives.py:1.1.2.1	Wed Jan 14 09:59:12 2004
+++ Zope3/src/zope/modulealias/metadirectives.py	Wed Jan 14 11:46:10 2004
@@ -17,5 +17,5 @@
 
 class IModuleAliasDirective(Interface):
     """ Define a new module alias """
-    source = PythonIdentifier()
-    target = PythonIdentifier()
+    module = PythonIdentifier()
+    alias = PythonIdentifier()




More information about the Zope3-Checkins mailing list