[Erp5-report] r40310 jm - in /erp5/trunk/products: ERP5/tests/ ERP5Type/

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Nov 16 21:27:51 CET 2010


Author: jm
Date: Tue Nov 16 21:27:50 2010
New Revision: 40310

URL: http://svn.erp5.org?rev=40310&view=rev
Log:
Fix CacheCookieMixin so that container is committed when a cookie is created

Added:
    erp5/trunk/products/ERP5/tests/testConflictResolution.py
Modified:
    erp5/trunk/products/ERP5Type/Cache.py

Added: erp5/trunk/products/ERP5/tests/testConflictResolution.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testConflictResolution.py?rev=40310&view=auto
==============================================================================
--- erp5/trunk/products/ERP5/tests/testConflictResolution.py (added)
+++ erp5/trunk/products/ERP5/tests/testConflictResolution.py [utf8] Tue Nov 16 21:27:50 2010
@@ -0,0 +1,70 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
+#          Julien Muchembled <jm at nexedi.com>
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsibility of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# guarantees and support are strongly advised to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+##############################################################################
+
+import unittest
+import urllib
+import transaction
+from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
+
+class TestConflictResolution(ERP5TypeTestCase):
+
+  def getTitle(self):
+    return "Conflict Resolution"
+
+  def afterSetUp(self):
+    other_node = self.getOtherZEOClientNode()
+    self.other_node = self.portal.portal_web_services.connect(
+      "http://%s%s" % (other_node, self.portal.getPath()),
+      'ERP5TypeTestCase', '', 'xml-rpc')
+    self.login()
+
+  def getOtherZEOClientNode(self):
+    from ZEO.ClientStorage import ClientStorage
+    storage = self.portal._p_jar._storage
+    activity_tool = self.portal.portal_activities
+    node_list = list(activity_tool.getProcessingNodeList())
+    node_list.remove(activity_tool.getCurrentNode())
+    assert node_list and isinstance(storage, ClientStorage), \
+      "this unit test must be run with at least 2 ZEO clients"
+    return node_list[0]
+
+  def testZODBCookie(self):
+    cookie_name = self._testMethodName
+    portal = self.portal
+    self.assertEqual(0, portal.getCacheCookie(cookie_name))
+    transaction.commit()
+    portal.newCacheCookie(cookie_name) # 1
+    self.other_node.newCacheCookie(cookie_name) # 1
+    self.other_node.newCacheCookie(cookie_name) # 2
+    transaction.commit() # max(1, 2) + 1
+    self.assertEqual(3, portal.getCacheCookie(cookie_name))
+
+def test_suite():
+  suite = unittest.TestSuite()
+  suite.addTest(unittest.makeSuite(TestConflictResolution))
+  return suite

Modified: erp5/trunk/products/ERP5Type/Cache.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Cache.py?rev=40310&r1=40309&r2=40310&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Cache.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Cache.py [utf8] Tue Nov 16 21:27:50 2010
@@ -90,7 +90,7 @@ class CacheCookieMixin:
     try:
       return self.__dict__[cache_name].value
     except KeyError:
-      self.__dict__[cache_name] = ZODBCookie()
+      setattr(self, cache_name, ZODBCookie())
       return ZODBCookie.value
 
   security.declareProtected(Permissions.ModifyPortalContent, 'newCacheCookie')
@@ -100,7 +100,7 @@ class CacheCookieMixin:
     try:
       self.__dict__[cache_name].value += 1
     except KeyError:
-      self.__dict__[cache_name] = ZODBCookie()
+      setattr(self, cache_name, ZODBCookie())
 
 
 class CacheFactory:




More information about the Erp5-report mailing list