allow specifying a zsql_brain parameter to select a brain class for...

allow specifying a zsql_brain parameter to select a brain class for ZSQLMethods from Extension files in products or BTs

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39356 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 87da5df6
......@@ -144,6 +144,10 @@ def DA__call__(self, REQUEST=None, __ick__=None, src__=0, test__=0, **kw):
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__=None, src__=0, test__=0, **kw):
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_)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment