Skip to content

Commit

Permalink
More work on an initial fully-functional version
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Johnson committed Jun 6, 2011
1 parent 34dbb3d commit eb906fb
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
Empty file added __init__.py
Empty file.
16 changes: 16 additions & 0 deletions config.py
@@ -0,0 +1,16 @@
from google.appengine.api import lib_config


class ConfigDefaults(object):
"""Configurable constants.
To override clio's configuration values, define values like this in your
appengine_config.py file (in the root of your app):
clio_FOO = 5
"""
QUEUE_URL = '/_clio/match'
QUEUE_NAME = 'default'


config = lib_config.register('clio', ConfigDefaults.__dict__)
17 changes: 17 additions & 0 deletions handler.py
@@ -0,0 +1,17 @@
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template
from google.appengine.ext.webapp.util import run_wsgi_app

from config import config


application = webapp.WSGIApplication([
])


def main():
run_wsgi_app(application)


if __name__ == "__main__":
main()
22 changes: 22 additions & 0 deletions middleware.py
@@ -0,0 +1,22 @@
import time
import webob

from google.appengine.api import prospective_search

from config import config
import model


class LoggingMiddleware(object):
def __init__(self, application):
self.application = application

def __call__(self, environ, start_response):
req = Request(environ)
start_time = time.time()
resp = req.get_response(self.application)
elapsed = time.time() - start_time
if config.config.should_record(env):
record = model.RequestRecord.create(request, response, elapsed)
prospective_search.match(record, config.QUEUE_URL, config.QUEUE_NAME)
return resp(environ, start_response)

0 comments on commit eb906fb

Please sign in to comment.