[Erp5-report] r41865 leonardo - in /erp5/trunk/products/CMFActivity: ./ tests/

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Dec 29 20:42:28 CET 2010


Author: leonardo
Date: Wed Dec 29 20:42:27 2010
New Revision: 41865

URL: http://svn.erp5.org?rev=41865&view=rev
Log:
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.

Modified:
    erp5/trunk/products/CMFActivity/ActivityConnection.py
    erp5/trunk/products/CMFActivity/tests/testCMFActivity.py

Modified: erp5/trunk/products/CMFActivity/ActivityConnection.py
URL: http://svn.erp5.org/erp5/trunk/products/CMFActivity/ActivityConnection.py?rev=41865&r1=41864&r2=41865&view=diff
==============================================================================
--- erp5/trunk/products/CMFActivity/ActivityConnection.py [utf8] (original)
+++ erp5/trunk/products/CMFActivity/ActivityConnection.py [utf8] Wed Dec 29 20:42:27 2010
@@ -29,6 +29,7 @@
 from Products.ZMySQLDA.DA import Connection
 from Products.ERP5Type.Globals import InitializeClass
 from App.special_dtml import HTMLFile
+from Acquisition import aq_parent
 
 # If the sort order below doesn't work, we cannot guarantee the setSortKey()
 # call below will actually result in the activity connection being committed
@@ -41,7 +42,7 @@ def manage_addActivityConnection(self, i
                                  connection_string,
                                  check=None, REQUEST=None):
     """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)
 
 class ActivityConnection(Connection):
@@ -59,10 +60,13 @@ class ActivityConnection(Connection):
 
     def 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
         # 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
 
 InitializeClass(ActivityConnection)

Modified: erp5/trunk/products/CMFActivity/tests/testCMFActivity.py
URL: http://svn.erp5.org/erp5/trunk/products/CMFActivity/tests/testCMFActivity.py?rev=41865&r1=41864&r2=41865&view=diff
==============================================================================
--- erp5/trunk/products/CMFActivity/tests/testCMFActivity.py [utf8] (original)
+++ erp5/trunk/products/CMFActivity/tests/testCMFActivity.py [utf8] Wed Dec 29 20:42:27 2010
@@ -3872,6 +3872,8 @@ class TestCMFActivity(ERP5TypeTestCase, 
         stdconn.title,
         stdconn.connection_string
     )
+    newconn = portal.cmf_activity_sql_connection
+    self.assertEquals(newconn.meta_type, 'CMFActivity Database Connection')
 
 def test_suite():
   suite = unittest.TestSuite()



More information about the Erp5-report mailing list