dabo Commit
Revision 3093
Date: 2007-04-27 12:53:21 -0700 (Fri, 27 Apr 2007)
Author: Ed
Trac: http://svn.dabodev.com/trac/dabo/changeset/3093
Changed:
U trunk/dabo/biz/dBizobj.py
Log:
Factored out the code that handles connections from __init__() to a separate
'setConnection()' method.
Diff:
Modified: trunk/dabo/biz/dBizobj.py
===================================================================
--- trunk/dabo/biz/dBizobj.py 2007-04-27 00:15:19 UTC (rev 3092)
+++ trunk/dabo/biz/dBizobj.py 2007-04-27 19:53:21 UTC (rev 3093)
@@ -17,7 +17,7 @@
_call_beforeInit, _call_afterInit, _call_initProperties = False, False,
False
- def __init__(self, conn, properties=None, *args, **kwargs):
+ def __init__(self, conn=None, properties=None, *args, **kwargs):
""" User code should override beforeInit() and/or afterInit()
instead."""
self.__att_try_setFieldVal = False
# Collection of cursor objects. MUST be defined first.
@@ -31,15 +31,7 @@
self._defaultValues = {}
self._beforeInit()
- cf = self._cursorFactory = conn
- if cf:
- # Base cursor class : the cursor class from the db api
- self.dbapiCursorClass = cf.getDictCursorClass()
-
- # If there are any problems in the createCursor
process, an
- # exception will be raised in that method.
- self.createCursor()
-
+ self.setConnection(conn)
# We need to make sure the cursor is created *before* the call
to
# initProperties()
self._initProperties()
@@ -99,6 +91,20 @@
self.beforeInit()
+ def setConnection(self, conn):
+ """Normally connections are established before bizobj creation,
but
+ for those cases where connections are created later, use this
method to
+ establish the connection used by the bizobj.
+ """
+ self._cursorFactory = conn
+ if conn:
+ # Base cursor class : the cursor class from the db api
+ self.dbapiCursorClass =
self._cursorFactory.getDictCursorClass()
+ # If there are any problems in the createCursor
process, an
+ # exception will be raised in that method.
+ self.createCursor()
+
+
def getTempCursor(self):
"""Occasionally it is useful to be able to run ad-hoc queries
against
the database. For these queries, where the results are not
meant to
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/dabo-dev/[EMAIL PROTECTED]