-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathappengine_config.py
41 lines (33 loc) · 1003 Bytes
/
appengine_config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""Configuration."""
import logging
logging.info('Loading %s from %s', __name__, __file__)
def webapp_add_wsgi_middleware(app):
try:
from appstats import recording
except ImportError, err:
logging.info('Failed to import recording: %s', err)
else:
app = recording.appstats_wsgi_middleware(app)
try:
from firepython import middleware
except ImportError, err:
logging.info('Failed to import firepython: %s', err)
else:
app = middleware.FirePythonWSGI(app)
return app
import re
# Declare the Django version we need.
from google.appengine.dist import use_library
use_library('django', '1.0')
import django
# Custom appstats path normalization.
def appstats_normalize_path(path):
if path.startswith('/user/'):
return '/user/X'
if path.startswith('/user_popup/'):
return '/user_popup/X'
if path.startswith('/rss/'):
i = path.find('/', 5)
if i > 0:
return path[:i] + '/X'
return re.sub(r'\d+', 'X', path)