[Vobject] vCard add (multiple children)

Jeffrey Harris jeffrey at osafoundation.org
Thu Apr 10 15:51:38 CDT 2008


Hi Neil,

> Thanks – conceptually that’s what I figured.  Am I missing something in 
> the docs – is there a ref on the syntax for something like –

>    j.tel_list.append(‘555-5555’)

Well, this isn't quite right (as you figured out).  j.tel_list is a list 
of vobject *nodes*.

There are two kinds of nodes, Components (which just have a name, and 
children), and ContentLines (that's what one of the RFCs calls 'em). 
ContentLines have a name, a value, and optional parameters.

So, what you want to append is a ContentLine whose name is "tel".

some_component.add("tel") is a shortcut that does this for you, it 
creates the new ContentLine, adds it to `some_component` and returns it.

So, you had it right in your first email,

 >>> j.add('tel').value = '555-5555'

does what you want, for any number of tel children.

>   j.tel_list.type_param.append(‘cell’)

If you want to add more detail then just a value, you could either save 
the return value from j.add, or do something like:

 >>> for tel in j.tel_list:
...    tel.type_param = 'cell'

Sincerely,
Jeffrey


More information about the VObject mailing list