Got a request to post my workaround:

    j = 3
    while True:
        if j < 1:
            print 'Unable to post Google event ' + title
            break
        try:
            new_event = cs.InsertEvent(event, '/calendar/feeds/
[email protected]/private/full')
        except gdata.service.RequestError as inst:
            # This was found experimentally.  inst is returned as a
sequence.
            # The zero'th element of inst is a dictionary with the
RequestError.
            thing = inst[0]
            if thing['status'] == 302:
                print 'Received redirect - retrying ' + title
                j = j - 1
                time.sleep(2.0)
                continue
            elif thing['status'] == 403:
                print 'Received forbidden - retrying ' + title
                j = j - 1
                time.sleep(5.0)
                continue
            else:
                # RequestError for something besides redirect
                raise
        except:
            # Some other exception
            raise
        break
    if j < 1:
        return 0

I've since added additional handling for the other annoying case,
sporadic 403 "Forbidden" errors.
The 302 handler has been exercised a fair amount by now.  Not so the
403 handler ... your
mileage may vary.

Cheers -

Bruce

--

You received this message because you are subscribed to the Google Groups 
"Google Calendar Data API" group.
To post to this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-calendar-help-dataapi?hl=.


Reply via email to