comparison 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
comparison
equal deleted inserted replaced
299:07ad8d8fde77 300:c5acb4995fde
245 245
246 def parseItemConfig(self, item): 246 def parseItemConfig(self, item):
247 """Get and remove item configuration information 247 """Get and remove item configuration information
248 @param item: 248 @param item:
249 """ 249 """
250 # FIXME: dirty ! Need to use elements()
251 item_config = None 250 item_config = None
252 access_model = const.VAL_AMODEL_DEFAULT 251 access_model = const.VAL_AMODEL_DEFAULT
253 for i in range(len(item.children)): 252 for idx, elt in enumerate(item.children):
254 elt = item.children[i] 253 if elt.uri != 'data_form.NS_X_DATA' or elt.name != 'x':
255 if not (elt.uri,elt.name)==(data_form.NS_X_DATA,'x'):
256 continue 254 continue
257 form = data_form.Form.fromElement(elt) 255 form = data_form.Form.fromElement(elt)
258 if (form.formNamespace == const.NS_ITEM_CONFIG): 256 if form.formNamespace == const.NS_ITEM_CONFIG:
259 item_config = form 257 item_config = form
260 del item.children[i] #we need to remove the config from item 258 del item.children[idx] #we need to remove the config from item
261 break 259 break
262 260
263 if item_config: 261 if item_config:
264 access_model = item_config.get(const.OPT_ACCESS_MODEL, const.VAL_AMODEL_DEFAULT) 262 access_model = item_config.get(const.OPT_ACCESS_MODEL, const.VAL_AMODEL_DEFAULT)
265
266 return (access_model, item_config) 263 return (access_model, item_config)
267
268 264
269 def _checkOverwrite(self, node, itemIdentifiers, publisher): 265 def _checkOverwrite(self, node, itemIdentifiers, publisher):
270 """Check that the itemIdentifiers correspond to items published 266 """Check that the itemIdentifiers correspond to items published
271 by the current publisher""" 267 by the current publisher"""
272 def doCheck(item_pub_map): 268 def doCheck(item_pub_map):