[Zope3-checkins] CVS: Zope3/src/zope/modulealias - metaconfigure.py:1.1.2.3

Chris McDonough chrism at plope.com
Wed Jan 14 12:01:40 EST 2004


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

Modified Files:
      Tag: steveachrismcd-securitypolicy-branch
	metaconfigure.py 
Log Message:
Test for attempts to alias things to objects other than modules.


=== Zope3/src/zope/modulealias/metaconfigure.py 1.1.2.2 => 1.1.2.3 ===
--- Zope3/src/zope/modulealias/metaconfigure.py:1.1.2.2	Wed Jan 14 11:46:10 2004
+++ Zope3/src/zope/modulealias/metaconfigure.py	Wed Jan 14 12:01:08 2004
@@ -16,11 +16,12 @@
 modulealiases package allows you to make module alias declarations via zcml,
 e.g.:
 
-<modulealias source="some.nonexistent.package" target="some.existing.package"/>
+<modulealias module="some.existing.package" alias="some.nonexistent.package" />
 $Id$
 """
 
 import sys
+import types
 
 class ModuleAliasException(Exception):
     pass
@@ -36,9 +37,13 @@
     """ define a module alias by munging sys.modules """
     module_ob = context.resolve(module)
     alias_ob = sys.modules.get(alias)
+    if not isinstance(module_ob, types.ModuleType):
+        raise ModuleAliasException(
+            '"module" %s does not resolve to a module' % module)
 
     if alias_ob is not None and alias_ob is not module_ob: 
-        raise ModuleAliasException(module, alias)
+        raise ModuleAliasException(
+            '"alias" module %s already exists in sys.modules' % alias)
     
     sys.modules[alias] = module_ob
 




More information about the Zope3-Checkins mailing list