[z3-checkins] r5486 - z3/sqlos/trunk

dreamcatcher at codespeak.net dreamcatcher at codespeak.net
Thu Jul 8 15:46:04 MEST 2004


Author: dreamcatcher
Date: Thu Jul  8 15:46:04 2004
New Revision: 5486

Modified:
   z3/sqlos/trunk/metaconfigure.py
Log:
But then issue a warning telling you to do so, because this may not interact completely cleanly with the checkers. (which are registered using the class as key) 

Modified: z3/sqlos/trunk/metaconfigure.py
==============================================================================
--- z3/sqlos/trunk/metaconfigure.py	(original)
+++ z3/sqlos/trunk/metaconfigure.py	Thu Jul  8 15:46:04 2004
@@ -10,6 +10,9 @@
 $Id: __init__.py 5216 2004-06-21 18:33:07Z dreamcatcher $
 """
 
+import sys
+import warnings
+
 from zope.interface.verify import verifyClass
 from zope.interface import directlyProvides, implements
 from zope.app.component.metaconfigure import factory, utility
@@ -36,11 +39,24 @@
     # If the class doesn't mix-in SQLOS, we do it for you, so that you
     # can use pure SQLObject classes, and they behave accordingly when
     # inside Zope3.
+    # However, we issue a warning as this may have unknown side-effects.
     if not issubclass(component, sqlos.SQLOS):
         c_dict = dict(vars(component))
+        m_name = component.__module__
+        c_name = component.__name__
+        warnings.warn("You forgot to subclass sqlos.SQLOS on "
+                      "the registered factory %s.%s. We are "
+                      "going to try to fix this, but this has "
+                      "unknown side-effects and may break in the future. "
+                      "Please fix this as soon as possible." %
+                      (m_name, c_name),
+                      Warning, 1)
         component = MetaSQLObject(component.__name__,
                                   (sqlos.SQLOS, component),
                                   c_dict)
+        # **Warning**: Monkeypatch ahead.
+        module = sys.modules[m_name]
+        setattr(module, c_name, component)
 
     factoryObj = SQLObjectFactory(component, title, description)
 


More information about the z3-checkins mailing list