Skip to content

Instantly share code, notes, and snippets.

@mbrenig
Created June 19, 2014 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbrenig/3d007fb8f5f98468a228 to your computer and use it in GitHub Desktop.
Save mbrenig/3d007fb8f5f98468a228 to your computer and use it in GitHub Desktop.
Monkey patch gdata.server
# BEGIN MONKEY PATCH!
# This works around a gdata issue with the 'new-style' google sheets.
# Specifically working around this issue:
# https://code.google.com/p/gdata-python-client/issues/detail?id=692
# Once api and gdata are fixed this should be removed.
import gdata.service
oldpp = gdata.service.GDataService.PostOrPut
def newpp(self, verb, *args, **kw):
if verb == 'PUT' or (verb == 'POST' and
type(args[0]).__name__ != 'SpreadsheetsWorksheet'):
if not kw.get('extra_headers'):
kw['extra_headers'] = { 'If-Match': '*' }
else:
kw['extra_headers']['If-Match'] = '*'
return oldpp(self, verb, *args, **kw)
gdata.service.GDataService.PostOrPut = newpp
# END MONKEY PATCH!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment