we've to call cleanup_sys_modules manually for proper schema modules cleanup
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 28 Jul 2009 11:04:41 +0200
changeset 2526 40e41eb34a7d
parent 2525 19eaaf9aebf2
child 2527 e60db6312aa0
we've to call cleanup_sys_modules manually for proper schema modules cleanup
schema.py
--- a/schema.py	Mon Jul 27 18:43:47 2009 +0200
+++ b/schema.py	Tue Jul 28 11:04:41 2009 +0200
@@ -21,7 +21,7 @@
 from yams.schema import Schema, ERSchema, EntitySchema, RelationSchema
 from yams.constraints import BaseConstraint, StaticVocabularyConstraint
 from yams.reader import CONSTRAINTS, PyFileReader, SchemaLoader, \
-     obsolete as yobsolete
+     obsolete as yobsolete, cleanup_sys_modules
 
 from rql import parse, nodes, RQLSyntaxError, TypeResolverException
 
@@ -868,7 +868,11 @@
             path = reversed([config.apphome] + config.cubes_path())
         else:
             path = reversed(config.cubes_path())
-        return super(CubicWebSchemaLoader, self).load(config, path=path, **kwargs)
+        try:
+            return super(CubicWebSchemaLoader, self).load(config, path=path, **kwargs)
+        finally:
+            # we've to cleanup modules imported from cubicweb.schemas as well
+            cleanup_sys_modules([self.lib_directory])
 
     def _load_definition_files(self, cubes):
         for filepath in (join(self.lib_directory, 'bootstrap.py'),