~renatofilho/+junk/contacts-service

« back to all changes in this revision

Viewing changes to examples/contacts.py

  • Committer: Renato Araujo Oliveira Filho
  • Date: 2013-05-16 14:48:24 UTC
  • Revision ID: renato.filho@canonical.com-20130516144824-hcc945sytgc2ysx8
Implemented contact update.

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
        return self.addr_iface.updateContacts([vcard])
48
48
 
49
49
    def create(self, vcard):
50
 
        print "CREATE:", self.addr_iface.createContact(vcard, "")
 
50
        return self.addr_iface.createContact(vcard, "")
51
51
 
52
52
 
53
53
service = Contacts()
58
58
        print contact
59
59
 
60
60
if "update" in sys.argv:
61
 
    contacts = service.query()
62
 
    service.update(contacts[0])
 
61
    vcard = VCARD_JOE
 
62
    contactId = service.create(vcard)
 
63
    vcard = vcard.replace("VERSION:3.0", "VERSION:3.0\nUID:%s" % (contactId))
 
64
    vcard = vcard.replace("N:Gump;Forrest", "N:Hanks;Tom")
 
65
    print service.update(vcard)
63
66
 
64
67
if "create" in sys.argv:
65
 
    contacts = service.create(VCARD_JOE)
 
68
    print "New UID:", service.create(VCARD_JOE)