示例#1
0
 def child_chunks():
     num_items = 0
     for item in items:
         num_items += 1
         if self.maxlength is not None and num_items > self.maxlength:
             msg = "Field '%s': too many items" % (self.field_name,)
             raise dexml.RenderError(msg)
         for data in self.field.render_children(obj,item,nsmap):
             yield data
     if self.minlength is not None and num_items < self.minlength:
         msg = "Field '%s': not enough items" % (self.field_name,)
         raise dexml.RenderError(msg)
示例#2
0
 def render_children(self,obj,item,nsmap):
     if item is None:
         if self.required:
             raise dexml.RenderError("Field '%s': required field is missing" % (self.field_name,))
     else:
         for data in item._render(nsmap=nsmap):
             yield data
示例#3
0
 def render_children(self, obj, items, nsmap):
     if self.minlength is not None and len(items) < self.minlength:
         raise dexml.RenderError("Field '%s': not enough items" % (self.field_name,))
     if self.maxlength is not None and len(items) > self.maxlength:
         raise dexml.RenderError("too many items")
     if self.tagname:
         children = "".join(data for item in items.values() for data in self.field.render_children(obj,item,nsmap))
         if not children:
             if self.required:
                 yield "<%s />" % (self.tagname,)
         else:
             yield children.join(('<%s>'%self.tagname, '</%s>'%self.tagname))
     else:
         for item in items.values():
             for data in self.field.render_children(obj, item, nsmap):
                 yield data