[Checkins] SVN: z3c.relationfield/trunk/ Be a bit more tolerant about missing relation attributes.

Martijn Faassen faassen at infrae.com
Thu Jan 8 11:04:17 EST 2009


Log message for revision 94626:
  Be a bit more tolerant about missing relation attributes.
  

Changed:
  U   z3c.relationfield/trunk/CHANGES.txt
  U   z3c.relationfield/trunk/src/z3c/relationfield/event.py

-=-
Modified: z3c.relationfield/trunk/CHANGES.txt
===================================================================
--- z3c.relationfield/trunk/CHANGES.txt	2009-01-08 15:03:46 UTC (rev 94625)
+++ z3c.relationfield/trunk/CHANGES.txt	2009-01-08 16:04:17 UTC (rev 94626)
@@ -11,6 +11,10 @@
 * Get rid of IRelationInfo adapter requirement. Just define a
   ``create_relation`` function that does the same work.
 
+* When looking for relations on an object be more tolerant if those
+  cannot be found (just skip them) - this can happen when a schema is
+  changed.
+
 0.1 (2008-12-05)
 ================
 

Modified: z3c.relationfield/trunk/src/z3c/relationfield/event.py
===================================================================
--- z3c.relationfield/trunk/src/z3c/relationfield/event.py	2009-01-08 15:03:46 UTC (rev 94625)
+++ z3c.relationfield/trunk/src/z3c/relationfield/event.py	2009-01-08 16:04:17 UTC (rev 94626)
@@ -104,10 +104,18 @@
     for iface in providedBy(obj).flattened():
         for name, field in getFields(iface).items():
             if IRelation.providedBy(field):
-                relation = getattr(obj, name)
+                try:
+                    relation = getattr(obj, name)
+                except AttributeError:
+                    # can't find this relation on the object
+                    continue
                 yield name, None, relation
             if IRelationList.providedBy(field):
-                l = getattr(obj, name)
+                try:
+                    l = getattr(obj, name)
+                except AttributeError:
+                    # can't find the relation list on this object
+                    continue
                 if l is not None:
                     for i, relation in enumerate(l):
                         yield name, i, relation



More information about the Checkins mailing list