Commit 3d7079ea authored by Chris Withers's avatar Chris Withers

Refactor, and check we have connection before we try and close it.

parent 2d15f94b
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
############################################################################## ##############################################################################
__doc__='''Generic Database Connection Support __doc__='''Generic Database Connection Support
$Id: Connection.py,v 1.36 2003/09/24 14:28:43 chrisw Exp $''' $Id: Connection.py,v 1.37 2003/10/22 20:33:56 chrisw Exp $'''
__version__='$Revision: 1.36 $'[11:-2] __version__='$Revision: 1.37 $'[11:-2]
import Globals, OFS.SimpleItem, AccessControl.Role, Acquisition, sys import Globals, OFS.SimpleItem, AccessControl.Role, Acquisition, sys
from DateTime import DateTime from DateTime import DateTime
...@@ -142,16 +142,19 @@ class Connection( ...@@ -142,16 +142,19 @@ class Connection(
manage_main=DTMLFile('dtml/connectionStatus', globals()) manage_main=DTMLFile('dtml/connectionStatus', globals())
def manage_close_connection(self, REQUEST): def manage_close_connection(self, REQUEST=None):
" " " "
try: self._v_database_connection.close() try:
if hasattr(self,'_v_database_connection'):
self._v_database_connection.close()
except: except:
LOG('Shared.DC.ZRDB.Connection', LOG('Shared.DC.ZRDB.Connection',
ERROR, ERROR,
'Error closing relational database connection.', 'Error closing relational database connection.',
error=exc_info()) error=exc_info())
self._v_connected='' self._v_connected=''
return self.manage_main(self, REQUEST) if REQUEST is not None:
return self.manage_main(self, REQUEST)
def manage_open_connection(self, REQUEST=None): def manage_open_connection(self, REQUEST=None):
" " " "
...@@ -169,13 +172,7 @@ class Connection( ...@@ -169,13 +172,7 @@ class Connection(
'''The database connection is not connected''') '''The database connection is not connected''')
def connect(self,s): def connect(self,s):
try: self._v_database_connection.close() self.manage_close_connection()
except:
LOG('Shared.DC.ZRDB.Connection',
ERROR,
'Error closing relational database connection.',
error=exc_info())
self._v_connected=''
DB=self.factory() DB=self.factory()
try: try:
try: try:
......
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