Re: Sample to retrieve user's profile and contacts using 2LO (issue 5554074)

18 views
Skip to first unread message

ala...@google.com

unread,
Jan 20, 2012, 6:36:47 PM1/20/12
to shra...@google.com, afs...@google.com, ccher...@google.com, vicf...@google.com, gdata-python-client-...@googlegroups.com, re...@codereview-hr.appspotmail.com
Out of curiosity, what is the purpose of this sample? There is already a
sample in the repository showing how to use 2-LO & batch requests on the
Profiles API.


http://codereview.appspot.com/5554074/diff/1/samples/apps/user_profile_contacts_2lo.py
File samples/apps/user_profile_contacts_2lo.py (right):

http://codereview.appspot.com/5554074/diff/1/samples/apps/user_profile_contacts_2lo.py#newcode35
samples/apps/user_profile_contacts_2lo.py:35: """Object to demonstrate
retrieval of domain user's profile and contacts."""
s/Object/Class/

http://codereview.appspot.com/5554074/diff/1/samples/apps/user_profile_contacts_2lo.py#newcode50
samples/apps/user_profile_contacts_2lo.py:50: requestor_id = 'admin@' +
self.consumer_key
This requires that the domain has an admin account named "admin".
Shouldn't you use the user_id?

http://codereview.appspot.com/5554074/diff/1/samples/apps/user_profile_contacts_2lo.py#newcode54
samples/apps/user_profile_contacts_2lo.py:54: self.client =
gdata.apps.client.AppsClient(
Rename this variable to remove confusion (e.g "apps_client").

http://codereview.appspot.com/5554074/diff/1/samples/apps/user_profile_contacts_2lo.py#newcode70
samples/apps/user_profile_contacts_2lo.py:70: print 'Email: %s
(primary)' % (email.address)
No need for parenthesis around email.address, apply throughout.

http://codereview.appspot.com/5554074/diff/1/samples/apps/user_profile_contacts_2lo.py#newcode93
samples/apps/user_profile_contacts_2lo.py:93: requestor_id = 'admin@' +
self.domain
Same comment about admin account.

http://codereview.appspot.com/5554074/diff/1/samples/apps/user_profile_contacts_2lo.py#newcode95
samples/apps/user_profile_contacts_2lo.py:95: entry_uri =
self.contacts_client.GetFeedUri('profiles')+'/'+user_id
Add spaces around the '+' operator.

http://codereview.appspot.com/5554074/diff/1/samples/apps/user_profile_contacts_2lo.py#newcode126
samples/apps/user_profile_contacts_2lo.py:126: user =
self.client.RetrieveUser(user_id)
What is the point of using this API when the same information is
returned by the Profiles API? (the question can be applied the other way
around).

http://codereview.appspot.com/5554074/diff/1/samples/apps/user_profile_contacts_2lo.py#newcode129
samples/apps/user_profile_contacts_2lo.py:129: profile =
self.GetProfile(user.login.user_name)
Can the user_id and user.login.user_name be different?

http://codereview.appspot.com/5554074/diff/1/samples/apps/user_profile_contacts_2lo.py#newcode134
samples/apps/user_profile_contacts_2lo.py:134: print contact
You can use PrintProfile to print the content of the contact entry
instead of printing raw XML.

http://codereview.appspot.com/5554074/diff/1/samples/apps/user_profile_contacts_2lo.py#newcode140
samples/apps/user_profile_contacts_2lo.py:140: usage = 'Usage: %prog
[options]'
Are the arguments optional? If not, put them in the Usage:
Usage: %prog --CONSUMER_KEY=<> --CONSUMER_SECRET=<> --USER_ID=<>

http://codereview.appspot.com/5554074/diff/1/samples/apps/user_profile_contacts_2lo.py#newcode151
samples/apps/user_profile_contacts_2lo.py:151: options.USER_ID):
Fix indentation.

http://codereview.appspot.com/5554074/diff/1/samples/apps/user_profile_contacts_2lo.py#newcode153
samples/apps/user_profile_contacts_2lo.py:153: return
Return an error code.

http://codereview.appspot.com/5554074/diff/1/samples/apps/user_profile_contacts_2lo.py#newcode155
samples/apps/user_profile_contacts_2lo.py:155: options.CONSUMER_SECRET)
Fix indentation.

http://codereview.appspot.com/5554074/diff/1/samples/apps/user_profile_contacts_2lo.py#newcode157
samples/apps/user_profile_contacts_2lo.py:157:
Add one blank line.

http://codereview.appspot.com/5554074/

vicf...@google.com

unread,
Jan 22, 2012, 1:50:49 AM1/22/12
to shra...@google.com, afs...@google.com, ccher...@google.com, ala...@google.com, gdata-python-client-...@googlegroups.com, re...@codereview-hr.appspotmail.com

http://codereview.appspot.com/5554074/diff/1/samples/apps/user_profile_contacts_2lo.py#newcode35
samples/apps/user_profile_contacts_2lo.py:35: """Object to demonstrate
retrieval of domain user's profile and contacts."""

On 2012/01/21 13:02:18, shraddhag wrote:
> On 2012/01/20 23:36:47, alainv wrote:
> > s/Object/Class/

> object is required keyword in parameter. Class gives an error.

Please further explain your previous comment.

http://codereview.appspot.com/5554074/diff/3001/samples/apps/user_profile_contacts_2lo.py
File samples/apps/user_profile_contacts_2lo.py (right):

http://codereview.appspot.com/5554074/diff/3001/samples/apps/user_profile_contacts_2lo.py#newcode51
samples/apps/user_profile_contacts_2lo.py:51: requestor_id = admin_id +
'@' + self.consumer_key
requestor_id = '%s@%s' % (admin_id, self.consumer_key)

http://codereview.appspot.com/5554074/diff/3001/samples/apps/user_profile_contacts_2lo.py#newcode55
samples/apps/user_profile_contacts_2lo.py:55: self.apps_client =
gdata.apps.client.AppsClient(
Can this be made into a single line < 80 chars?

http://codereview.appspot.com/5554074/

Reply all
Reply to author
Forward
0 new messages