changeset 379:d40b744a9d99

serve: Add a generic WSGI app factory.
author Ludovic Chabant <ludovic@chabant.com>
date Sat, 09 May 2015 08:48:58 -0700
parents fe8a58817088
children f33712c4cfab
files piecrust/wsgiutil/__init__.py piecrust/wsgiutil/cwdapp.py
diffstat 2 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/piecrust/wsgiutil/__init__.py	Sat May 09 08:37:32 2015 -0700
+++ b/piecrust/wsgiutil/__init__.py	Sat May 09 08:48:58 2015 -0700
@@ -0,0 +1,10 @@
+from piecrust.serving.server import Server
+
+
+def get_app(root_dir, sub_cache_dir='prod', enable_debug_info=False):
+    server = Server(root_dir,
+                    sub_cache_dir=sub_cache_dir,
+                    enable_debug_info=enable_debug_info)
+    app = server.getWsgiApp()
+    return app
+
--- a/piecrust/wsgiutil/cwdapp.py	Sat May 09 08:37:32 2015 -0700
+++ b/piecrust/wsgiutil/cwdapp.py	Sat May 09 08:48:58 2015 -0700
@@ -2,12 +2,11 @@
 # like Werkzeug or Gunicorn. It returns a WSGI app for serving a PieCrust
 # website located in the current working directory.
 import os
-from piecrust.serving.server import Server
+from piecrust.wsgiutil import get_app
 
 
 root_dir = os.getcwd()
-server = Server(root_dir, sub_cache_dir='prod', enable_debug_info=False)
-app = server.getWsgiApp()
+app = get_app(root_dir)
 # Add this for `mod_wsgi`.
 application = app