[Vobject] How to split name values?

Jeffrey Harris jeffrey at osafoundation.org
Tue Jun 10 12:46:43 CDT 2008


Hi Steffen,

> In vcard.py is some code handling the name parts, but I can't figure out 
> how to use it.

You did everything right, except that you're using a version 2.1 vcard. 
  When I originally did the (rudimentary) vcard support for vobject, I 
focused on vcard 3.0 since it's much better behaved.

When readComponents sees a version line, it goes and looks for 
"behaviors" associated with the component name and version number.  It's 
not finding anything for vcard 2.1, so it doesn't assign a behavior.

The behavior is what converts vcard/icalendar strings into more useful 
python objects.

You can manually set the vcard 3.0 behavior with setBehavior.  You'll 
want to pass cascade=True so the method cascades and sets behaviors for 
children, e.g.:

c.setBehavior(vobject.vcard.VCard3_0, True)

There seems to be a lot of interest in vcards these days, but I don't do 
much with them.  I'd love to get a patch that makes a specific behavior 
for 2.1 vcards, if that scratches someone else's itch.

> If there are several TEL entries (like TEL;WORK and TEL;FAX), they are 
> all merged together as a list. Is there any way to address the FAX value 
>   directly? My current code iterates over the list and compares 
> singletonparams with "FAX".

Singletonparams are a goofiness of vcard 2.1, I went ahead and took a 
patch that makes them parse successfully, but I haven't added any 
further functionality for querying them, so iterating and comparing is 
the best thing to do for now.

Sincerely,
Jeffrey


More information about the VObject mailing list