[Erp5-report] r39356 leonardo - /erp5/trunk/products/ERP5Type/patches/DA.py

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Oct 19 17:16:19 CEST 2010


Author: leonardo
Date: Tue Oct 19 17:16:17 2010
New Revision: 39356

URL: http://svn.erp5.org?rev=39356&view=rev
Log:
allow specifying a zsql_brain parameter to select a brain class for ZSQLMethods from Extension files in products or BTs

Modified:
    erp5/trunk/products/ERP5Type/patches/DA.py

Modified: erp5/trunk/products/ERP5Type/patches/DA.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/patches/DA.py?rev=39356&r1=39355&r2=39356&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/patches/DA.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/patches/DA.py [utf8] Tue Oct 19 17:16:17 2010
@@ -144,6 +144,10 @@ def DA__call__(self, REQUEST=None, __ick
     c = kw.pop("connection_id", None)
     #if c is not None:
       #LOG("DA", 300, "connection %s provided to %s" %(c, self.id))
+    # patch: dynamic brain configuration
+    zsql_brain = kw.pop('zsql_brain', None) 
+    # patch end
+    
       
     if REQUEST is None:
         if kw: REQUEST=kw
@@ -225,7 +229,19 @@ def DA__call__(self, REQUEST=None, __ick
         LOG("DA call raise", ERROR, "DB = %s, c = %s, query = %s" %(DB__, c, query), error=sys.exc_info())
         raise
 
-    if hasattr(self, '_v_brain'): brain=self._v_brain
+    # patch: dynamic brain configuration
+    if zsql_brain is not None:
+        try:
+          class_file_, class_name_ = zsql_brain.rsplit('.', 1)
+        except:
+          #import pdb; pdb.post_mortem()
+          raise
+        brain = getBrain(class_file_, class_name_)
+        # XXX remove this logging for performance
+        LOG(__name__, INFO, "Using special brain: %r\n" % (brain,))
+    elif hasattr(self, '_v_brain'):
+    # end patch:
+        brain=self._v_brain
     else:
         brain=self._v_brain=getBrain(self.class_file_, self.class_name_)
 




More information about the Erp5-report mailing list