GData Calendar 501 Error

3 views
Skip to first unread message

Elmore

unread,
Oct 1, 2008, 9:37:38 PM10/1/08
to Google App Engine
I'm trying to use the the GData Python library to create a calendar
for a user. The logon (client based) works, getting the calendar feed
works, but then the code chokes on the InsertCalendar call. Here is
the snippet:

# Check for the master Google calendar, if not present create
one
calendar_service = gdata.calendar.service.CalendarService()
gdata.alt.appengine.run_on_appengine(calendar_service)
calendar_service.email = g_user
calendar_service.password = g_pass
calendar_service.source = GOOGLE_DICT['api-source']
calendar_service.ProgrammaticLogin()
logging.info(calendar_service.GetClientLoginToken()) <----
things are okay here

# Create the default calendar, if it is not there
feed = calendar_service.GetOwnCalendarsFeed()
logging.info('Obtained a feed: ' + feed.title.text) <----
things are okay here

if 'mydefault' not in ( c.title.text for c in feed.entry ):
logging.info('Default calendar not found, creating!')
calendar = gdata.calendar.CalendarListEntry()
calendar.title = atom.Title(text='mydefault')
new_calendar =
calendar_service.InsertCalendar(new_calendar=calendar) <---- Bombs
here!
logging.info(new_calendar.title)

The insert bombs with a 501 from the Googles <snipped>:

File "C:\Program Files\Google\google_appengine\academic\admin.py",
line 92, in post
new_calendar =
calendar_service.InsertCalendar(new_calendar=calendar)
File "C:\Program Files\Google\google_appengine\academic\gdata
\calendar\service.py", line 197, in InsertCalendar
converter=gdata.calendar.CalendarListEntryFromString)
File "C:\Program Files\Google\google_appengine\academic\gdata
\service.py", line 831, in Post
media_source=media_source, converter=converter)
File "C:\Program Files\Google\google_appengine\academic\gdata
\service.py", line 951, in PostOrPut
'reason': server_response.reason, 'body': result_body}
RequestError: {'status': 501, 'body': '\n\n<html><head>\n<meta http-
equiv="content-type" content="text/html;charset=utf-8">\n<title>501
Not Implemented</title>\

I am using the latest iterations of GAE and the Python lib (Local Dev
1.1.4 and GData Python 1.2.1).

I added the following at the top of my file just after my imports, but
to no avail:

gdata.service.http_request_handler = gdata.urlfetch

Any ideas / suggestions?

Jeff S

unread,
Oct 3, 2008, 2:36:56 PM10/3/08
to Google App Engine
Hi Elmore,

I'm guessing that this 501 error will only occur when your code is
running in the SDK. The Calendar service sometimes responds with a 302
redirect and the SDK's version of urlfetch retries the POST as a GET,
which is why the Calendar server responds with "Not Implemented". On
the App Engine servers, urlfetch will correctly retry with a POST so
this is not an issue if you've uploaded your app.

I added a workaround for this issue in revision 534 of the gdata-
python-client: http://code.google.com/p/gdata-python-client/source/detail?r=534
You can either add this change into your copy of the library, checkout
the latest revision from subversion, or wait for a future release :)

Happy coding,

Jeff

Elmore

unread,
Oct 3, 2008, 7:16:22 PM10/3/08
to Google App Engine
Yes. I'm still building the next killer app only the SDK for now
(killer in my mind anyway)

Yes. R-534 fixes my problem. I downloaded the file and will update on
the next release...

Yes. People from the Googles will answer questions...

Gracias senor Jeff...
Reply all
Reply to author
Forward
0 new messages