[Zope3-checkins] CVS: Zope3/src/zodb/code - module.py:1.3

Jeremy Hylton jeremy@zope.com
Mon, 30 Dec 2002 14:14:37 -0500


Update of /cvs-repository/Zope3/src/zodb/code
In directory cvs.zope.org:/tmp/cvs-serv1004

Modified Files:
	module.py 
Log Message:
Add helper newModule().


=== Zope3/src/zodb/code/module.py 1.2 => 1.3 ===
--- Zope3/src/zodb/code/module.py:1.2	Wed Dec 25 09:12:18 2002
+++ Zope3/src/zodb/code/module.py	Mon Dec 30 14:14:36 2002
@@ -102,6 +102,12 @@
 
 __persistent_module_registry__ = "__persistent_module_registry__"
 
+def newModule(registry, name, source):
+    """Return a manager object for a newly created module."""
+    mgr = PersistentModuleManager(registry)
+    mgr.new(name, source)
+    return mgr
+
 class PersistentModuleManager(Persistent):
 
     __implements__ = IPersistentModuleManager
@@ -290,6 +296,8 @@
 
     def setModule(self, name, module):
         if name in self.__modules:
+            # The name is already in use.
+            # XXX should raise a better error
             raise ValueError, name
         self._p_changed = True
         self.__modules[name] = module