Fix test failures on testBusinessTemplate and spurious error messages on the...

Fix test failures on testBusinessTemplate and spurious error messages on the console when trying to set the sort_key on an unconnected Connection object. Also fix the manual creation of the ActivityConnection object.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41865 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f44cddef
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
from Products.ZMySQLDA.DA import Connection from Products.ZMySQLDA.DA import Connection
from Products.ERP5Type.Globals import InitializeClass from Products.ERP5Type.Globals import InitializeClass
from App.special_dtml import HTMLFile from App.special_dtml import HTMLFile
from Acquisition import aq_parent
# If the sort order below doesn't work, we cannot guarantee the setSortKey() # If the sort order below doesn't work, we cannot guarantee the setSortKey()
# call below will actually result in the activity connection being committed # call below will actually result in the activity connection being committed
...@@ -41,7 +42,7 @@ def manage_addActivityConnection(self, id, title, ...@@ -41,7 +42,7 @@ def manage_addActivityConnection(self, id, title,
connection_string, connection_string,
check=None, REQUEST=None): check=None, REQUEST=None):
"""Add a DB connection to a folder""" """Add a DB connection to a folder"""
self._setObject(id, Connection(id, title, connection_string, check)) self._setObject(id, ActivityConnection(id, title, connection_string, check))
if REQUEST is not None: return self.manage_main(self,REQUEST) if REQUEST is not None: return self.manage_main(self,REQUEST)
class ActivityConnection(Connection): class ActivityConnection(Connection):
...@@ -59,10 +60,13 @@ class ActivityConnection(Connection): ...@@ -59,10 +60,13 @@ class ActivityConnection(Connection):
def connect(self, s): def connect(self, s):
result = Connection.connect(self, s) result = Connection.connect(self, s)
if aq_parent(self) is None:
# Connection.connect() doesn't set _v_database_connection if there
# are no acquisition wrappers
return result
# the call above will set self._v_database_connection, and it won't # the call above will set self._v_database_connection, and it won't
# have disappeared by now. # have disappeared by now.
# We need to put back this code as soon as problems are solved XXX self._v_database_connection.setSortKey( (0,) )
#self._v_database_connection.setSortKey( (0,) )
return result return result
InitializeClass(ActivityConnection) InitializeClass(ActivityConnection)
...@@ -3872,6 +3872,8 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor): ...@@ -3872,6 +3872,8 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
stdconn.title, stdconn.title,
stdconn.connection_string stdconn.connection_string
) )
newconn = portal.cmf_activity_sql_connection
self.assertEquals(newconn.meta_type, 'CMFActivity Database Connection')
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
......
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