Overnight API doesn't work any more?

8 views
Skip to first unread message

HT

unread,
Nov 18, 2009, 3:40:06 PM11/18/09
to Google Documents List API
I've written a simple piece of educational software in Python an I use
Google Documents List API. Last Monday the program worked fine. When I
ran the program on Tuesday, however, it didn't anymore. As I have not
changed the code of the program in months, I was wondering how this
happened and, more importantly, how to solve the problem.

Somehow, my program is unable to find a (newly created or old) folder.
I store the IDs of folders in a database and use the ID to retrieve
the folder entry with a simple (but stupid) function:

def get_folder_entry_by_id(self, id):
q = gdata.docs.service.DocumentQuery(categories=['folder'],
params={'showfolders': 'true'})
feed = self.connection.Query( q.ToUri() )
for entry in feed.entry:
if entry.resourceId.text == id:
return entry
return False

This piece of code now returns False instead of the folder entry I am
looking for, whereas two days ago it always found the folder I was
looking for.

(by the way, if someone has a nicer solution to get an entry given an
ID, I appreciate the solution)

Any suggestions?

Thanks

Eric (Google)

unread,
Nov 18, 2009, 5:28:52 PM11/18/09
to Google Documents List API
Some others have reported this, so I've opened a public issue:
http://code.google.com/p/gdata-issues/issues/detail?id=1634

Please start to follow it.

A work around for you would be to query for the folder entry
directly (since you have it's resource id):

uri = 'http://docs.google.com/feeds/documents/private/full/' + id
folder_entry = self.connection.Query(uri)
print folder_entry .resourceId.text == id

Eric

HT

unread,
Nov 19, 2009, 4:56:40 AM11/19/09
to Google Documents List API
Thanks for the solution to get a document/folder directly by its ID. I
don't know how I've overlooked that! :-(

Unfortunately, the solution does not seem to work. In the code snippet
below, I successfully create a folder and get an ID. If I then
immediately try to get the folder-entry by using your work around,
folder_entry is None.

assignmentlink = self.connection.CreateFolder(
assignment.title,
class_link)

aid = assignmentlink.resourceId.text

print aid
uri = 'http://docs.google.com/feeds/documents/private/full/' + aid
print uri
folder_entry = self.connection.Query(uri)
print folder_entry

Somehow the folders do get created (they appear in my Google Docs
account) but I can't access them via the API. I am using version 2.0.1
of the Python gdata API. Maybe this version is outdated?

Eric (Google)

unread,
Nov 20, 2009, 1:04:04 PM11/20/09
to Google Documents List API
The folder issue should be resolved, but to answer your questions...

What happens if you wait a few seconds after creating
the folder and before querying for it?

BTW, v3.0 code was just checked in if you're interested:
http://code.google.com/p/gdata-python-client/source/detail?r=881

HT

unread,
Nov 21, 2009, 8:41:11 AM11/21/09
to Google Documents List API
The folder issue is fixed, thanks for that!

But I am unable to get a folder by its ID, even if I wait a day, the
folder_entry returns up None.

Eric (Google)

unread,
Nov 23, 2009, 3:25:47 PM11/23/09
to Google Documents List API
I think this is because when you query the entry directly using
the v2.0 methods (Query and GetDocumentsListFeed), it's expecting
a feed from the server. Instead, you're getting an entry.

The v3.0 code that I linked to addresses this by providing
a GetDoc method:

client = gdata.docs.client.DocsClient()
folder_resource_id = 'folder%3A0B9kVjMzJkNjYz'
folder_entry = client.GetDoc(folder_resource_id)

If you don't want to update your app just yet, you could
use the v2.0 service class's Query method and pass
in the correct converter:

client = gdata.docs.service.DocsService()
uri = 'http://docs.google.com/feeds/documents/private/full/' + id
folder_entry = client.Query(uri,
converter=gdata.docs.DocumentListEntryFromString)

http://code.google.com/p/gdata-python-client/source/browse/trunk/src/gdata/docs/service.py#203

Can you give one of those a go?

Eric
Reply all
Reply to author
Forward
0 new messages