Example #1
0
# coding: utf-8

import os
import sys

from path_util import sys_path_insert


if os.environ.get('SERVER_SOFTWARE', '').startswith('Google App Engine'):
  sys_path_insert('lib.zip')
else:
  if os.name == 'nt':
    os.name = None
    sys.platform = ''

  import re
  from google.appengine.tools.devappserver2.python import stubs

  re_ = stubs.FakeFile._skip_files.pattern.replace('|^lib/.*', '')
  re_ = re.compile(re_)
  stubs.FakeFile._skip_files = re_
  sys_path_insert('lib')

sys_path_insert('libx')

def webapp_add_wsgi_middleware(app):
  from google.appengine.ext.appstats import recording
  app = recording.appstats_wsgi_middleware(app)
  return app
Example #2
0
# coding: utf-8

import os
import sys

from path_util import sys_path_insert

if os.environ.get('SERVER_SOFTWARE', '').startswith('Google App Engine'):
    sys_path_insert('lib.zip')
else:
    if os.name == 'nt':
        os.name = None
        sys.platform = ''

    import re
    from google.appengine.tools.devappserver2.python import runtime

    try:
        re_ = runtime.stubs.FakeFile._skip_files.pattern.replace(
            '|^lib/.*', '')
        re_ = re.compile(re_)
        runtime.stubs.FakeFile._skip_files = re_
    except AttributeError:
        # runtime.stubs doesn't exist in the test environment
        pass
    sys_path_insert('lib')

sys_path_insert('libx')


def webapp_add_wsgi_middleware(app):
tempfile.SpooledTemporaryFile = tempfile.TemporaryFile

if os.environ.get('SERVER_SOFTWARE', '').startswith('Google App Engine'):
    pass
else:
    if os.name == 'nt':
        os.name = None
        sys.platform = ''

    import re
    from google.appengine.tools.devappserver2.python import runtime

    re_ = runtime.stubs.FakeFile._skip_files.pattern.replace('|^lib/.*', '')
    re_ = re.compile(re_)
    runtime.stubs.FakeFile._skip_files = re_
    sys_path_insert('lib')

sys_path_insert('lib')

import logging
import os
import random
import re

# 0) WSGI middleware declaration.

# Only use this if you're not Django; with Django, it's easier to add
#   'google.appengine.ext.appstats.recording.AppstatsDjangoMiddleware',
# to your Django settings.py file.