Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Cookie Auth Monkey Patch (NOT NEEDED AFTER 1.7.7)

By: bossylobster on Mar 29th, 2013  |  syntax: Python  |  size: 0.72 KB  |  views: 159  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. # NOT NEEDED AFTER APP ENGINE VERSION 1.7.7
  2.  
  3. import json
  4. import logging
  5.  
  6. from google.appengine.ext.endpoints import api_config
  7.  
  8.  
  9. class PatchedApiConfigGenerator(api_config.ApiConfigGenerator):
  10.   def pretty_print_config_to_json(self, services, hostname=None):
  11.     logging.warn('TODO: remove this monkey patch after GAE version 1.7.7')
  12.     # Sorry, the next line is not PEP8 compatible :(
  13.     json_string = super(PatchedApiConfigGenerator, self).pretty_print_config_to_json(
  14.         services, hostname=hostname)
  15.     to_patch = json.loads(json_string)
  16.     to_patch['auth'] = {'allowCookieAuth': True}
  17.     return json.dumps(to_patch, sort_keys=True, indent=2)
  18.  
  19.  
  20. api_config.ApiConfigGenerator = PatchedApiConfigGenerator