Closed GoogleCodeExporter closed 9 years ago
Could I see the code you use to construct your client as well?
Original comment by jscud.w...@gmail.com
on 1 Sep 2009 at 8:40
I can confirm that neither reading nor writing Birthdays seems to work with
python
gdata 2.0.5
My reading code
# birthday
if contact.birthday:
birthday = contact.birthday.when
addr.add_entry("birthday", birthday)
My writing code
# 'birthday' in form "2010-01-01"
if addr['birthday']:
birthday = addr['birthday'][0]
contact.birthday = gdata.contacts.Birthday(when=birthday)
addr is my own object to hold the info locally
I can roundtrip the birthday through local objects, but when I try to sync it
to or
from google it just vanishes.
Possibly related to this, but the relation field does the same thing - ie isn't
synced to or from google.
Reading code
# 'spouse', 'children'
children = []
if contact.relation:
for relation in contact.relation:
if relation.rel == 'spouse':
addr.add_entry("spouse", relation.text)
elif relation.rel == 'child':
children.append(relation.text)
else:
print "Unknown relation %s=%s" % (relation.rel, relation.text)
if children:
addr.add_entry("children", ", ".join(children))
Writing code
# 'spouse', 'children'
if addr['spouse']:
contact.relation.append(gdata.contacts.Relation(text=addr['spouse'][0],
rel='spouse'))
if addr['children']:
for child in ",".join(addr['children']).split(","):
contact.relation.append(gdata.contacts.Relation(text=child, rel='child'))
These roundtrip fine through local objects but don't sync to or from google.
These attributes were all introduced in Contacts API version 3.0 which may have
something to do with it
Original comment by nic...@gmail.com
on 4 Jan 2010 at 11:05
This bug appears to be present in 2.0.6 also
Original comment by nic...@gmail.com
on 4 Jan 2010 at 11:22
This bug appears to be present in 2.0.7 also
Original comment by nic...@gmail.com
on 29 Jan 2010 at 1:55
This problem still exists in 2.0.9
To replicate, apply this patch to the contacts_example.py
This will let you read and write birthdays
------------------------------------------------------------
--- contacts_example.py 2008-12-02 02:35:42.000000000 +0000
+++ contacts_example_ncw.py 2010-04-12 12:54:34.000000000 +0100
@@ -84,6 +84,7 @@
else:
value = extended_property.GetXmlBlobString()
print ' Extended Property %s: %s' % (extended_property.name, value)
+ print ' Birthday %s' % (entry.birthday)
return len(feed.entry) + ctr
def PrintPaginatedFeed(self, feed, print_method):
@@ -167,12 +168,14 @@
name = raw_input('Enter contact\'s name: ')
notes = raw_input('Enter notes for contact: ')
primary_email = raw_input('Enter primary email address: ')
+ birthday = raw_input('Birthday YYYY-MM-DD: ')
new_contact = gdata.contacts.ContactEntry(title=atom.Title(text=name))
new_contact.content = atom.Content(text=notes)
# Create a work email address for the contact and use as primary.
new_contact.email.append(gdata.contacts.Email(address=primary_email,
primary='true', rel=gdata.contacts.REL_WORK))
+ new_contact.birthday = gdata.contacts.Birthday(when=birthday)
entry = self.gd_client.CreateContact(new_contact)
if entry:
------------------------------------------------------------
Now try it out with a test account
------------------------------------------------------------
Contacts Sample
1) List all of your contacts.
2) Create a contact.
3) Query contacts on updated time.
4) Modify a contact.
5) Delete a contact.
6) List all of your contact groups.
7) Query your groups on updated time.
8) Exit.
> 2
Enter contact's name: Test
Enter notes for contact: Test
Enter primary email address: Test@Test.com
Birthday YYYY-MM-DD: 1990-01-01
Creation successful!
ID for the new contact:
http://www.google.com/m8/feeds/contacts/xxxxxxxxxxxxxxx%40googlemail.com/base/xx
xxxxxxxxxxxxxx
------------------------------------------------------------
I checked this on the web interface - The contact was created but no
birthday was added.
I tried to read it back anyway with no luck
------------------------------------------------------------
> 3
Enter updated min (example: 2007-03-16T00:00:00): 2010-04-12T00:00:00
1 Test
Test
Test@Test.com
Birthday None
------------------------------------------------------------
I then added a birthday using the web interface to the new contact and
tried to read it back with no luck
------------------------------------------------------------
> 3
Enter updated min (example: 2007-03-16T00:00:00): 2010-04-12T00:00:00
1 Test
Test
Test@Test.com
Birthday None
------------------------------------------------------------
Original comment by nic...@gmail.com
on 12 Apr 2010 at 12:06
I just retested this with gdata-2.0.10 with the same results
Does anyone ever look at these bug reports?
Original comment by nic...@gmail.com
on 2 Jun 2010 at 4:13
Actually I finally figured this one out...
When you create the contacts service, pass in some additional headers, and the
birthday field will work
gd_client = gdata.contacts.service.ContactsService(additional_headers =
{gdata.contacts.service.GDATA_VER_HEADER: 3})
This should be the default I think - all the documentation references API v3
Original comment by nic...@gmail.com
on 2 Jun 2010 at 4:25
nickcw, now birthday works fine, but how I can set contact full name?
contact.name = gdata.data.Name(
given_name=gdata.data.GivenName(text=person.full_name),
full_name=gdata.data.FullName(text=person.full_name)
)
this code doesn't work :(
Original comment by Roman.Su...@gmail.com
on 27 Jun 2010 at 1:04
@Roman.Suprotkin
Doesn't look wrong...
I don't think you can see these fields in the web interface though.
How do you know it isn't working? Do you get an error, or just can't read the
data back?
Original comment by nic...@gmail.com
on 28 Jun 2010 at 11:06
@nickcw,
When I set contact name via web I see in XML (from web)
<ns0:title>Some Name</ns0:title>
<ns1:name>
<ns1:fullName>Some Name</ns1:fullName>
<ns1:givenName>Some Name</ns1:givenName>
</ns1:name>
I'm trying to set Full Name with code
if not hasattr(contact, 'title') or not contact.title:
contact.title = atom.Title()
contact.title.text = person.full_name
contact.name = gdata.data.Name(
given_name=gdata.data.GivenName(text=person.full_name),
full_name=gdata.data.FullName(text=person.full_name)
)
contact.nickname = gdata.contacts.Nickname(text=person.full_name)
As result I see only Nickname via web.
XML (from web) looks like
<ns0:title />
<ns2:nickname xmlns:ns2="http://schemas.google.com/contact/2008">Some
Name</ns2:nickname>
There is no <ns1:name/> in XML
Original comment by Roman.Su...@gmail.com
on 29 Jun 2010 at 5:53
http://code.google.com/intl/ru/apis/contacts/docs/3.0/migration_guide.html
* Add an HTTP version header (GData-Version: 3.0) to every HTTP request you
send.
* Replace the uses of atom:title in contact entries by uses of gd:name.
* Replace the uses of gd:postalAddress in contact and contact group entries by
uses of gd:structuredPostalAddress.
Original comment by Roman.Su...@gmail.com
on 29 Jun 2010 at 5:58
How do you add an HTTP version header (GData-Version: 3.0) in Python? The
migration guide doesn't give an example of this.
Original comment by dpp.ph...@gmail.com
on 4 Oct 2010 at 3:28
gd_client = gdata.contacts.service.ContactsService(additional_headers =
{gdata.contacts.service.GDATA_VER_HEADER: 3})
Original comment by Roman.Su...@gmail.com
on 4 Oct 2010 at 6:29
This has been fixed in gdata.contacts.data module.
Original comment by ala...@google.com
on 7 Oct 2011 at 9:40
Original issue reported on code.google.com by
laeuf...@gmail.com
on 25 Aug 2009 at 2:26