diff sat_pubsub/backend.py @ 300:c5acb4995fde

cleaner parseItemConfig
author Goffi <goffi@goffi.org>
date Wed, 25 Nov 2015 16:00:08 +0100
parents 07ad8d8fde77
children 05c875a13a62
line wrap: on
line diff
--- a/sat_pubsub/backend.py	Wed Nov 25 15:58:42 2015 +0100
+++ b/sat_pubsub/backend.py	Wed Nov 25 16:00:08 2015 +0100
@@ -247,25 +247,21 @@
         """Get and remove item configuration information
         @param item:
         """
-        # FIXME: dirty ! Need to use elements()
         item_config = None
         access_model = const.VAL_AMODEL_DEFAULT
-        for i in range(len(item.children)):
-            elt = item.children[i]
-            if not (elt.uri,elt.name)==(data_form.NS_X_DATA,'x'):
+        for idx, elt in enumerate(item.children):
+            if elt.uri != 'data_form.NS_X_DATA' or elt.name != 'x':
                 continue
             form = data_form.Form.fromElement(elt)
-            if (form.formNamespace == const.NS_ITEM_CONFIG):
+            if form.formNamespace == const.NS_ITEM_CONFIG:
                 item_config = form
-                del item.children[i] #we need to remove the config from item
+                del item.children[idx] #we need to remove the config from item
                 break
 
         if item_config:
             access_model = item_config.get(const.OPT_ACCESS_MODEL, const.VAL_AMODEL_DEFAULT)
-
         return (access_model, item_config)
 
-
     def _checkOverwrite(self, node, itemIdentifiers, publisher):
         """Check that the itemIdentifiers correspond to items published
         by the current publisher"""