Permalink
Browse files

Added expose_environ to WSGIGateway

git-svn-id: https://svn.pyamf.org/pyamf/trunk@804 2dde4cc4-cf3c-0410-b1a3-a9b8ff274da5
  • Loading branch information...
1 parent c9fa8f8 commit 105b902c5574a291231446927ebb0462013f44f4 @njoyce njoyce committed with njoyce Jan 10, 2008
Showing with 19 additions and 3 deletions.
  1. +2 −0 CHANGES.txt
  2. +17 −3 pyamf/remoting/wsgigateway.py
View
@@ -8,6 +8,8 @@ of PyAMF.
0.1b (unreleased)
-------------------
+ - Added 'expose_environ' argument to WSGIGateway to expose the WSGI environ
+ as the first arg in the called services.
- Implemented Local Shared Object (LSO) support (Ticket:11)
- dicts are now used as the default for anonymous objects (Ticket:131)
- remoting.client mostly fully supports the predefined headers (defined at
@@ -21,7 +21,12 @@ class WSGIGateway(gateway.BaseGateway):
WSGI Remoting Gateway.
"""
- def getResponse(self, request):
+ def __init__(self, services={}, expose_environ=True):
+ gateway.BaseGateway.__init__(self, services)
+
+ self.expose_environ = expose_environ
+
+ def getResponse(self, request, environ):
"""
Processes the AMF request, returning an AMF response.
@@ -31,9 +36,18 @@ def getResponse(self, request):
@return: The AMF Response.
"""
response = remoting.Envelope(request.amfVersion, request.clientType)
+
+ kwargs = {}
+
+ if self.expose_environ:
+ def wrapper(service_request, *body):
+ return service_request(environ, *body)
+
+ kwargs.update({'service_wrapper': wrapper})
for name, message in request:
- response[name] = self.getProcessor(message)(message)
+ processor = self.getProcessor(message)
+ response[name] = processor(message, **kwargs)
return response
@@ -88,7 +102,7 @@ def __call__(self, environ, start_response):
# Process the request
try:
- response = self.getResponse(request)
+ response = self.getResponse(request, environ)
except (KeyboardInterrupt, SystemExit):
raise
except:

0 comments on commit 105b902

Please sign in to comment.