Created
January 4, 2013 23:58
-
-
Save joar/4458624 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From 7bbd7c5eb636673337f43ce3c9a9f3df58c9dfb7 Mon Sep 17 00:00:00 2001 | |
| From: Joar Wandborg <[email protected]> | |
| Date: Sat, 5 Jan 2013 00:58:18 +0100 | |
| Subject: [PATCH] Tornado test | |
| --- | |
| mediagoblin/app.py | 5 +++-- | |
| run_tornado.py | 26 ++++++++++++++++++++++++++ | |
| 2 files changed, 29 insertions(+), 2 deletions(-) | |
| create mode 100644 run_tornado.py | |
| diff --git a/mediagoblin/app.py b/mediagoblin/app.py | |
| index c163669..98aa0ca 100644 | |
| --- a/mediagoblin/app.py | |
| +++ b/mediagoblin/app.py | |
| @@ -156,7 +156,9 @@ class MediaGoblinApp(object): | |
| ## Attach utilities to the request object | |
| # Do we really want to load this via middleware? Maybe? | |
| - request.session = request.environ['beaker.session'] | |
| + # | |
| + # XXX: Breaks under tornado | |
| + request.session = request.environ.get('beaker.session', {}) | |
| # Attach self as request.app | |
| # Also attach a few utilities from request.app for convenience? | |
| request.app = self | |
| @@ -227,7 +229,6 @@ class MediaGoblinApp(object): | |
| def __call__(self, environ, start_response): | |
| ## If more errors happen that look like unclean sessions: | |
| # self.db.check_session_clean() | |
| - | |
| try: | |
| return self.call_backend(environ, start_response) | |
| finally: | |
| diff --git a/run_tornado.py b/run_tornado.py | |
| new file mode 100644 | |
| index 0000000..564c5da | |
| --- /dev/null | |
| +++ b/run_tornado.py | |
| @@ -0,0 +1,26 @@ | |
| +from tornado.httpserver import HTTPServer | |
| +from tornado.ioloop import IOLoop | |
| + | |
| +import tornado.wsgi | |
| +import tornado.web | |
| + | |
| +from mediagoblin.app import MediaGoblinApp | |
| + | |
| +if __name__ == '__main__': | |
| + app = MediaGoblinApp('mediagoblin_local.ini') | |
| + | |
| + wsgi_app = tornado.wsgi.WSGIContainer(app) | |
| + | |
| + tornado_app = tornado.web.Application([ | |
| + ('/mgoblin_media/(.*)', tornado.web.StaticFileHandler, | |
| + {'path': 'user_dev/media/public'}), | |
| + ('/mgoblin_static/(.*)', tornado.web.StaticFileHandler, | |
| + {'path': 'mediagoblin/static'}), | |
| + ('/theme_static/(.*)', tornado.web.StaticFileHandler, | |
| + {'path': 'user_dev/theme_static'}), | |
| + ('.*', tornado.web.FallbackHandler, dict(fallback=wsgi_app))]) | |
| + | |
| + server = HTTPServer(tornado_app) | |
| + server.listen(8181) | |
| + | |
| + IOLoop.instance().start() | |
| -- | |
| 1.7.10.4 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment