Skip to content
Browse files

De-emphasized the example_app for services that doesn't do anything i…

…nteresting yet
  • Loading branch information...
1 parent 2bef90d commit 72d8a5aa9088720841321f8e4177d7ceb63f7368 Simon Willison committed May 11, 2009
Showing with 43 additions and 23 deletions.
  1. +1 −0 djng/wsgi.py
  2. +0 −23 example_app.py
  3. +42 −0 example_services_incomplete.py
View
1 djng/wsgi.py
@@ -58,6 +58,7 @@ def apply_response_fixes(self, request, response):
BaseHTTPRequestHandler, WSGIServer
class WSGIRequestHandler(WSGIRequestHandlerOld):
+ # Just enough to get rid of settings.py dependencies
def __init__(self, *args, **kwargs):
self.path = ''
BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
View
23 example_app.py
@@ -1,23 +0,0 @@
-from djng.services.cache import CacheConfigure
-
-def view(request):
- from djng.services.cache import cache
- counter = cache.get('counter')
- if not counter:
- counter = 1
- else:
- counter += 1
- cache.set('counter', counter)
- print counter
-
-app = CacheConfigure(
- in_memory = True,
- next = view
-)
-
-app(None)
-app(None)
-app(None)
-app(None)
-app(None)
-
View
42 example_services_incomplete.py
@@ -0,0 +1,42 @@
+from djng import services
+from djng.services.cache import CacheConfigure
+
+# Default service configuration
+services.configure('cache', CacheConfigure(
+ in_memory = True,
+))
+# Or maybe this:
+# services.cache.configure(CacheConfigure(in_memory = True))
+# Or even:
+# services.cache.configure(in_memory = True)
+# Or...
+# services.default('cache', InMemoryCache())
+# Or...
+# services.configure('cache', InMemoryCache())
+
+def app(request):
+ from djng.services.cache import cache
+ counter = cache.get('counter')
+ if not counter:
+ counter = 1
+ else:
+ counter += 1
+ cache.set('counter', counter)
+ print counter
+
+app(None)
+app(None)
+
+# Middleware that reconfigures service for the duration of the request
+app = services.wrap(app, 'cache', InMemoryCache())
+
+# Or...
+app = services.wrap(app,
+ cache = InMemoryCache(),
+)
+
+
+app(None)
+app(None)
+app(None)
+

0 comments on commit 72d8a5a

Please sign in to comment.
Something went wrong with that request. Please try again.