tracker/rietveld /


import logging
import os
import re

from google.appengine.ext.appstats import recording'Loading %s from %s', __name__, __file__)

# Custom webapp middleware to add Appstats.
def webapp_add_wsgi_middleware(app):
  app = recording.appstats_wsgi_middleware(app)
  return app

# 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 '/diff/' in path:
      return '/X/diff/...'
    if '/diff2/' in path:
      return '/X/diff2/...'
    if '/patch/' in path:
      return '/X/patch/...'
    if path.startswith('/rss/'):
        i = path.find('/', 5)
        if i > 0:
            return path[:i] + '/X'
    return re.sub(r'\d+', 'X', path)

# Declare the Django version we need.
from google.appengine.dist import use_library
use_library('django', '1.2')

# Django 1.2 requires DJANGO_SETTINGS_MODULE environment variable to be set
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
# NOTE: All "main" scripts must import webapp.template before django.