[Code-review] review: Gadget act-props branch
Dafydd Harries
dafydd.harries at collabora.co.uk
Wed Aug 13 07:42:06 EDT 2008
Ar 12/08/2008 am 10:58, ysgrifennodd Guillaume Desmottes:
> Le lundi 11 août 2008 à 20:28 +0100, Dafydd Harries a écrit :
> > Ar 11/08/2008 am 20:21, ysgrifennodd Guillaume Desmottes:
> > > Le lundi 11 août 2008 à 14:07 +0100, Dafydd Harries a écrit :
> > > > act-props:
> > > >
> > > > >+ properties = activity_elem.addElement((ns.ACTIVITY_PROP, 'properties'))
> > > > >+ for node in properties_to_xml(activity.properties):
> > > > >+ properties.addChild(node)
> > > >
> > > > We seem to do this a lot. Let's change it so properties_to_xml returns the
> > > > <properties> element, then we can just say:
> > > >
> > > > activity_elem.addChild(properties_to_xml(activity.properties))
> > >
> > >
> > > The old code used to do that and you asked me to change to this current
> > > form :)
> >
> > Hmm, I think it was slightly different. It used to be that you passed in the
> > parent node, and properties_to_xml called addElement on it. I think when I
> > asked you to change it, I didn't realise you could pass in existing elements
> > to addChild.
>
> Oh, I see. Good idea, I did that.
>
> > > > > for child in node.elements():
> > > > >+ if child.uri == ns.ACTIVITY_PROP and child.name == 'properties':
> > > > >+ for child in child.elements():
> > > > >+ assert child.name == 'property'
> > > >
> > > > I think it's better to just ignore unexpected elements:
> > > >
> > > > for child in child.elements():
> > > > if child.name != 'property':
> > > > continue
Oops: I didn't realise that this was in the test code. I don't think it
matters there.
--
Dafydd
More information about the Code-review
mailing list