[Testbot] Plone 5.0 - Python 2.7 - Build # 1939 - Improvement! - 7 failure(s)

jenkins at plone.org jenkins at plone.org
Wed Mar 12 16:29:06 UTC 2014


-------------------------------------------------------------------------------
Plone 5.0 - Python 2.7 - Build # 1939 - Still Failing!
-------------------------------------------------------------------------------

http://jenkins.plone.org/job/plone-5.0-python-2.7/1939/


-------------------------------------------------------------------------------
CHANGES
-------------------------------------------------------------------------------

Repository: plone.app.contentrules
Branch: refs/heads/master
Date: 2014-03-02T17:45:10-06:00
Author: Nathan Van Gheem (vangheem) <vangheem at gmail.com>
Commit: https://github.com/plone/plone.app.contentrules/commit/e3a7a91c209f4708bb5afd04d3c0fbf21ca90e12

do not write on read

Files changed:
M CHANGES.rst
M plone/app/contentrules/api.py
M plone/app/contentrules/browser/controlpanel.py
M plone/app/contentrules/browser/elements.py
M plone/app/contentrules/rule.py
M plone/app/contentrules/tests/test_rule_assignment_mapping.py

diff --git a/CHANGES.rst b/CHANGES.rst
index c0beb12..c8f0518 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -4,7 +4,8 @@ Changelog
 3.0.7 (unreleased)
 ------------------
 
-- Nothing changed yet.
+- Do not write on read
+  [vangheem]
 
 
 3.0.6 (2014-01-27)
diff --git a/plone/app/contentrules/api.py b/plone/app/contentrules/api.py
index 4eb119b..d6612a7 100644
--- a/plone/app/contentrules/api.py
+++ b/plone/app/contentrules/api.py
@@ -2,7 +2,7 @@
 from plone.contentrules.engine.assignments import RuleAssignment
 from plone.contentrules.engine.interfaces import IRuleStorage,\
     IRuleAssignmentManager
-from plone.app.contentrules.rule import get_assignments
+from plone.app.contentrules.rule import get_assignments, insert_assignment
 
 
 def assign_rule(container, rule_id, enabled=True, bubbles=True,
@@ -31,7 +31,7 @@ def assign_rule(container, rule_id, enabled=True, bubbles=True,
     assignable[rule_id].enabled = bool(enabled)
     assignable[rule_id].bubbles = bool(bubbles)
     path = '/'.join(container.getPhysicalPath())
-    get_assignments(storage[rule_id]).insert(path)
+    insert_assignment(storage[rule_id], path)
 
     if insert_before:
         position = None
diff --git a/plone/app/contentrules/browser/controlpanel.py b/plone/app/contentrules/browser/controlpanel.py
index 39f1a7e..bbdf443 100644
--- a/plone/app/contentrules/browser/controlpanel.py
+++ b/plone/app/contentrules/browser/controlpanel.py
@@ -140,4 +140,4 @@ def globally_enable(self):
         storage = getUtility(IRuleStorage)
         storage.active = True
         return translate(_("Content rules has been globally enabled"),
-                         context=self.request)
\ No newline at end of file
+                         context=self.request)
diff --git a/plone/app/contentrules/browser/elements.py b/plone/app/contentrules/browser/elements.py
index 2c34d88..f7f6c8f 100644
--- a/plone/app/contentrules/browser/elements.py
+++ b/plone/app/contentrules/browser/elements.py
@@ -221,4 +221,4 @@ def _move_down(self, elements, idx):
     def globally_assign(self):
         self.authorize()
         portal = getToolByName(self.context, 'portal_url').getPortalObject()
-        api.assign_rule(portal, self.context.__name__)
\ No newline at end of file
+        api.assign_rule(portal, self.context.__name__)
diff --git a/plone/app/contentrules/rule.py b/plone/app/contentrules/rule.py
index b58eb83..e3c8bb7 100644
--- a/plone/app/contentrules/rule.py
+++ b/plone/app/contentrules/rule.py
@@ -29,12 +29,18 @@ def id(self):
 
 def get_assignments(rule):
     annotations = IAnnotations(rule)
-    return annotations.setdefault(ANNOTATION_KEY, OOSet())
+    # do not use setdefault here as it'll write to the database on read
+    return annotations.get(ANNOTATION_KEY, OOSet())
 
 
-# Events that keep track of rule-to-assignment mappings
+def insert_assignment(rule, path):
+    annotations = IAnnotations(rule)
+    if ANNOTATION_KEY not in annotations:
+        annotations[ANNOTATION_KEY] = OOSet()
+    annotations[ANNOTATION_KEY].insert(path)
 
 
+# Events that keep track of rule-to-assignment mappings
 def rule_removed(rule, event):
 
     storage = queryUtility(IRuleStorage)
@@ -54,7 +60,8 @@ def rule_removed(rule, event):
 
 def container_moved(container, event):
 
-    if event.oldParent is None or event.newParent is None or event.oldName is None:
+    if event.oldParent is None or event.newParent is None or \
+            event.oldName is None:
         return
 
     assignable = IRuleAssignmentManager(container, None)
@@ -63,7 +70,8 @@ def container_moved(container, event):
     if assignable is None or storage is None:
         return
 
-    old_path = "%s/%s" % ('/'.join(event.oldParent.getPhysicalPath()), event.oldName, )
+    old_path = "%s/%s" % ('/'.join(event.oldParent.getPhysicalPath()),
+                          event.oldName, )
     new_path = '/'.join(container.getPhysicalPath())
 
     if aq_base(event.object) is not aq_base(container):
diff --git a/plone/app/contentrules/tests/test_rule_assignment_mapping.py b/plone/app/contentrules/tests/test_rule_assignment_mapping.py
index 991a97d..8f956bc 100644
--- a/plone/app/contentrules/tests/test_rule_assignment_mapping.py
+++ b/plone/app/contentrules/tests/test_rule_assignment_mapping.py
@@ -7,7 +7,7 @@
 from plone.contentrules.engine.assignments import RuleAssignment
 
 from plone.app.contentrules.rule import Rule
-from plone.app.contentrules.rule import get_assignments
+from plone.app.contentrules.rule import get_assignments, insert_assignment
 
 from plone.app.contentrules.tests.base import ContentRulesTestCase
 from plone.app.contentrules import api
@@ -27,14 +27,17 @@ def afterSetUp(self):
 
         self.f11a = IRuleAssignmentManager(self.folder.f1.f11)
         self.f11a['r1'] = RuleAssignment('r1', bubbles=True)
-        get_assignments(self.storage['r1']).insert('/'.join(self.folder.f1.f11.getPhysicalPath()))
+        insert_assignment(self.storage['r1'],
+                          '/'.join(self.folder.f1.f11.getPhysicalPath()))
 
         self.f12a = IRuleAssignmentManager(self.folder.f1.f12)
         self.f12a['r1'] = RuleAssignment('r1', bubbles=True)
-        get_assignments(self.storage['r1']).insert('/'.join(self.folder.f1.f12.getPhysicalPath()))
+        insert_assignment(self.storage['r1'],
+                          '/'.join(self.folder.f1.f12.getPhysicalPath()))
 
         self.f12a['r2'] = RuleAssignment('r2', bubbles=True)
-        get_assignments(self.storage['r2']).insert('/'.join(self.folder.f1.f12.getPhysicalPath()))
+        insert_assignment(self.storage['r2'],
+                          '/'.join(self.folder.f1.f12.getPhysicalPath()))
 
     def testRuleRemoved(self):
         self.assertTrue('r1' in self.f11a)
@@ -131,4 +134,3 @@ def test_suite():
     suite = TestSuite()
     suite.addTest(makeSuite(TestRuleAssignmentMapping))
     return suite
-




-------------------------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CHANGES.log
Type: application/octet-stream
Size: 6439 bytes
Desc: not available
URL: <http://lists.plone.org/pipermail/plone-testbot/attachments/20140312/8c3b1257/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: build.log
Type: application/octet-stream
Size: 168360 bytes
Desc: not available
URL: <http://lists.plone.org/pipermail/plone-testbot/attachments/20140312/8c3b1257/attachment-0003.obj>


More information about the Testbot mailing list