[Vobject] Creating a vcard with multiple addresses

Jonathan Kaczynski jmkacz at gmail.com
Wed Dec 31 15:50:00 CST 2008


I've looked at the documentation and tests, but I'm not sure how to create a
vcard with multiple addresses. I can parse a vcard with multiple addresses.

Here's what I am doing:

import vobject

v = vobject.vCard()

v.add('n')
v.n.value = vobject.vcard.Name( given='John', family='Smith' )

v.add('fn')
v.fn.value = 'John Smith'

v.add('adr')
adrs = []
adrs.append( vobject.vcard.Address( street='123 Main Street' ) )
adrs.append( vobject.vcard.Address( street='1313 Mockingbird Lane' ) )
v.adr_list = adrs

print v.serialize()

On serialize, I receive the following stack trace:

Traceback (most recent call last):
  File "./vobject_adr3.py", line 19, in <module>
    print v.serialize()
  File "/var/lib/python-support/python2.5/vobject/base.py", line 186, in
serialize
    return behavior.serialize(self, buf, lineLength, validate)
  File "/var/lib/python-support/python2.5/vobject/behavior.py", line 148, in
serialize
    if validate: cls.validate(obj, raiseException=True)
  File "/var/lib/python-support/python2.5/vobject/behavior.py", line 83, in
validate
    if not child.validate(raiseException, complainUnrecognized):
AttributeError: 'Address' object has no attribute 'validate'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.skyhouseconsulting.com/pipermail/vobject/attachments/20081231/19b74d62/attachment.htm 


More information about the VObject mailing list