[Testbot] Plone 4.3 - Python 2.7 - Build # 2566 - Regression! - 5 failure(s)

jenkins at plone.org jenkins at plone.org
Mon Sep 22 15:52:48 UTC 2014


-------------------------------------------------------------------------------
Plone 4.3 - Python 2.7 - Build # 2566 - Failure!
-------------------------------------------------------------------------------

http://jenkins.plone.org/job/plone-4.3-python-2.7/2566/


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

Repository: plone.dexterity
Branch: refs/heads/master
Date: 2014-09-22T16:57:30+02:00
Author: Johannes Raggam (thet) <raggam-nl at adm.at>
Commit: https://github.com/plone/plone.dexterity/commit/9d0d3380b7ef9b243ebc8d4062c4d1f4c6e9b95e

avoid hasattr

Files changed:
M CHANGES.rst
M plone/dexterity/utils.py

diff --git a/CHANGES.rst b/CHANGES.rst
index 4109099..38ffd1b 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -10,6 +10,10 @@ Changelog
   see #20.
   [datakurre]
 
+- Let utils.createContent also handle setting of attributes on behaviors, which
+  derive from other behaviors.
+  [thet]
+
 - overhaul (no logic changed): 
   pep8, sorted imports plone.api style, readability, utf8header, 
   remove bbb code (plone 3)
@@ -26,10 +30,6 @@ Changelog
 2.2.2 (2014-04-13)
 ------------------
 
-- Let utils.createContent also handle setting of attributes on behaviors, which
-  derive from other behaviors.
-  [thet]
-
 - Add a 'success' class to the status message shown after successfully
   adding or editing an item.  The previous 'info' class is also
   retained for backwards-compatibility.
diff --git a/plone/dexterity/utils.py b/plone/dexterity/utils.py
index 5735555..b59b737 100644
--- a/plone/dexterity/utils.py
+++ b/plone/dexterity/utils.py
@@ -42,7 +42,7 @@ class SchemaNameEncoder(object):
         ('.', '_2_'),
         ('-', '_3_'),
         ('/', '_4_'),
-        )
+    )
 
     def encode(self, s):
         for k, v in self.key:
@@ -132,11 +132,20 @@ def createContent(portal_type, **kw):
     fields = dict(kw)  # create a copy
 
     for schema in schemas:
+        # schema.names() doesn't return attributes from superclasses in derived
+        # schemas. therefore we have to iterate over all items from the passed
+        # keywords arguments and set it, if the behavior has the questioned
+        # attribute.
         behavior = schema(content)
         for name, value in fields.items():
-            if hasattr(behavior, name):
-                setattr(behavior, name, value)
-                del fields[name]
+            try:
+                # hasattr swallows exceptions.
+                if getattr(behavior, name):
+                    setattr(behavior, name, value)
+                    del fields[name]
+            except AttributeError:
+                # fieldname not available
+                pass
 
     for (key, value) in fields.items():
         setattr(content, key, value)




-------------------------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CHANGES.log
Type: application/octet-stream
Size: 2429 bytes
Desc: not available
URL: <http://lists.plone.org/pipermail/plone-testbot/attachments/20140922/9ca68072/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: build.log
Type: application/octet-stream
Size: 87140 bytes
Desc: not available
URL: <http://lists.plone.org/pipermail/plone-testbot/attachments/20140922/9ca68072/attachment-0003.obj>


More information about the Testbot mailing list