[Checkins] SVN: megrok.z3cform.base/trunk/src/megrok/z3cform/base/ Changed function name and code, for a better readability. Added tests accordingly

Souheil CHELFOUH souheil at chelfouh.com
Wed Oct 7 07:13:25 EDT 2009


Log message for revision 104852:
  Changed function name and code, for a better readability. Added tests accordingly

Changed:
  U   megrok.z3cform.base/trunk/src/megrok/z3cform/base/__init__.py
  U   megrok.z3cform.base/trunk/src/megrok/z3cform/base/tests/test_utils.py
  U   megrok.z3cform.base/trunk/src/megrok/z3cform/base/utils.py

-=-
Modified: megrok.z3cform.base/trunk/src/megrok/z3cform/base/__init__.py
===================================================================
--- megrok.z3cform.base/trunk/src/megrok/z3cform/base/__init__.py	2009-10-07 11:08:44 UTC (rev 104851)
+++ megrok.z3cform.base/trunk/src/megrok/z3cform/base/__init__.py	2009-10-07 11:13:25 UTC (rev 104852)
@@ -11,4 +11,4 @@
 from components import *
 from directives import *
 from interfaces import IGrokForm, ICancelButton
-from utils import apply_data_event, changes_notification, set_fields_data
+from utils import apply_data_event, notify_changes, set_fields_data

Modified: megrok.z3cform.base/trunk/src/megrok/z3cform/base/tests/test_utils.py
===================================================================
--- megrok.z3cform.base/trunk/src/megrok/z3cform/base/tests/test_utils.py	2009-10-07 11:08:44 UTC (rev 104851)
+++ megrok.z3cform.base/trunk/src/megrok/z3cform/base/tests/test_utils.py	2009-10-07 11:13:25 UTC (rev 104852)
@@ -5,7 +5,11 @@
   >>> changes = set_fields_data(Fields(IPerson), person, {'name': u'james'})
   >>> changes
   {<InterfaceClass megrok.z3cform.base.tests.test_utils.IPerson>: ['name']}
- 
+  >>> attributes = notify_changes(person, changes)
+  An IObjectModifiedEvent was sent for a person with the following changes:
+  name
+  >>> attributes
+  [<zope.lifecycleevent.Attributes object at ...>]
   
 """
 import grokcore.component as grok

Modified: megrok.z3cform.base/trunk/src/megrok/z3cform/base/utils.py
===================================================================
--- megrok.z3cform.base/trunk/src/megrok/z3cform/base/utils.py	2009-10-07 11:08:44 UTC (rev 104851)
+++ megrok.z3cform.base/trunk/src/megrok/z3cform/base/utils.py	2009-10-07 11:13:25 UTC (rev 104852)
@@ -29,7 +29,7 @@
     return changes
 
 
-def changes_notification(content, changes):
+def notify_changes(content, changes):
     """Builds a list of descriptions, made of Attributes objects, defining
     the changes made on the content and the related interface.
     """
@@ -38,7 +38,7 @@
         for interface, names in changes.items():
             descriptions.append(Attributes(interface, *names))
             notify(ObjectModifiedEvent(content, *descriptions))
-        return description
+        return descriptions
     return None
 
 
@@ -46,8 +46,8 @@
     """ Updates the object with the data and sends an IObjectModifiedEvent
     """
     changes = set_fields_data(fields, content, data)
-    changes and changes_notification(content, changes)
+    if changes: notify_changes(content, changes)
     return changes
 
 
-__all__ = ("set_fields_data", "changes_notification", "apply_data_event")
+__all__ = ("set_fields_data", "notify_changes", "apply_data_event")



More information about the checkins mailing list