[Checkins] SVN: hurry.resource/branches/janjaapdriessen-resource-publisher/src/hurry/resource/ anticipate on passing on configuration to the needed inclusions object in the inject middleware
Jan-Wijbrand Kolman
janwijbrand at gmail.com
Tue Nov 23 11:30:25 EST 2010
Log message for revision 118538:
anticipate on passing on configuration to the needed inclusions object in the inject middleware
Changed:
U hurry.resource/branches/janjaapdriessen-resource-publisher/src/hurry/resource/README.txt
U hurry.resource/branches/janjaapdriessen-resource-publisher/src/hurry/resource/publisher.py
U hurry.resource/branches/janjaapdriessen-resource-publisher/src/hurry/resource/wsgi.py
-=-
Modified: hurry.resource/branches/janjaapdriessen-resource-publisher/src/hurry/resource/README.txt
===================================================================
--- hurry.resource/branches/janjaapdriessen-resource-publisher/src/hurry/resource/README.txt 2010-11-23 16:16:56 UTC (rev 118537)
+++ hurry.resource/branches/janjaapdriessen-resource-publisher/src/hurry/resource/README.txt 2010-11-23 16:30:24 UTC (rev 118538)
@@ -1063,7 +1063,7 @@
We now wrap this in our middleware, so that the middleware is activated::
>>> from hurry.resource.wsgi import InjectMiddleWare
- >>> wrapped_app = InjectMiddleWare(app)
+ >>> wrapped_app = InjectMiddleWare(app, hurry.resource.publisher_signature)
Now we make a request (using webob for convenience)::
@@ -1089,7 +1089,8 @@
... needed = environ['hurry.resource.needed'] = NeededInclusions()
... needed.need(y1)
... return ['<html><head></head><body</body></html>']
- >>> wrapped_app = InjectMiddleWare(app)
+ >>> import hurry.resource
+ >>> wrapped_app = InjectMiddleWare(app, hurry.resource.publisher_signature)
>>> req = webob.Request.blank('/')
>>> res = req.get_response(wrapped_app)
>>> res.body
Modified: hurry.resource/branches/janjaapdriessen-resource-publisher/src/hurry/resource/publisher.py
===================================================================
--- hurry.resource/branches/janjaapdriessen-resource-publisher/src/hurry/resource/publisher.py 2010-11-23 16:16:56 UTC (rev 118537)
+++ hurry.resource/branches/janjaapdriessen-resource-publisher/src/hurry/resource/publisher.py 2010-11-23 16:30:24 UTC (rev 118538)
@@ -49,13 +49,13 @@
class Delegator(object):
- def __init__(self, app):
+ def __init__(self, app, signature):
self.application = app
self.resource_publisher = Publisher()
def __call__(self, environ, start_response):
path_info = environ['PATH_INFO']
- trigger = '/%s/' % hurry.resource.publisher_signature
+ trigger = '/%s/' % signature
chunks = path_info.split(trigger, 1)
if len(chunks) == 1:
# The trigger is not in the URL at all, we delegate to the
@@ -65,8 +65,8 @@
environ['PATH_INFO'] = '/%s' % chunks[1]
return self.resource_publisher(environ, start_response)
-def make_delegator(app, global_conf):
- return Delegator(app)
+def make_delegator(app, global_conf, **local_conf):
+ return Delegator(app, hurry.resource.publisher_signature)
"""
def cache_header_start_response(status, headers, exc_info=None):
Modified: hurry.resource/branches/janjaapdriessen-resource-publisher/src/hurry/resource/wsgi.py
===================================================================
--- hurry.resource/branches/janjaapdriessen-resource-publisher/src/hurry/resource/wsgi.py 2010-11-23 16:16:56 UTC (rev 118537)
+++ hurry.resource/branches/janjaapdriessen-resource-publisher/src/hurry/resource/wsgi.py 2010-11-23 16:30:24 UTC (rev 118538)
@@ -1,4 +1,5 @@
import webob
+import hurry.resource
NEEDED = 'hurry.resource.needed'
@@ -9,12 +10,16 @@
class InjectMiddleWare(object):
- def __init__(self, application):
+ def __init__(self, application, signature):
self.application = application
def __call__(self, environ, start_response):
request = webob.Request(environ)
+ # XXX the needed inclusions object is created here and the
+ # signature should be set on it as would the mode and dev_mode
+ # etcetera.
+
# Get the response from the wrapped application:
response = request.get_response(self.application)
@@ -30,6 +35,6 @@
response.body = needed.render_topbottom_into_html(response.body)
return response(environ, start_response)
-
def make_inject(app, global_config, **local_config):
- return InjectMiddleWare(app, **local_config)
+ return InjectMiddleWare(
+ app, hurry.resource.publisher_signature, **local_config)
More information about the checkins
mailing list