Beispiel #1
0
 def decode(node, errs, where):
     l = []
     nodes = xmlext.getAllNodes(node, path)
     #print node, tag + '/' + comp_tag, nodes
     if len(nodes)==0 and req==mandatory:
         errs.append(where + ': ' + _('Mandatory list "%s" under "%s" node is empty.') % (path, node.name()))
     ix = 1
     for node in nodes:
         dummy = xmlext.newNode(node, "Dummy")
         xmlext.addNode(dummy, '', node)
         l.append(decode_item(dummy, errs, where + str("[%s]" % ix)))
         #l.append(decode_item(node, errs, where + unicode("[%s]" % ix)))
         ix += 1
     return l
Beispiel #2
0
 def encode(node, obj, errs):
     if node and obj:
         try:
             #FIXME: this doesn't look pretty
             classnode = xmlext.newNode(node, tag)
             obj.encode(classnode, errs)
             xmlext.addNode(node, '', classnode)
         except Error:
             if req == mandatory:
                 # note: we can receive an error if obj has no content
                 errs.append(_('Object cannot be encoded'))
     else:
         if req == mandatory:
             errs.append(_('Mandatory argument not available'))