Skip to content

Commit

Permalink
Added expose_environ to WSGIGateway
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.pyamf.org/pyamf/trunk@804 2dde4cc4-cf3c-0410-b1a3-a9b8ff274da5
  • Loading branch information
njoyce committed Jan 10, 2008
1 parent c9fa8f8 commit 105b902
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Expand Up @@ -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
Expand Down
20 changes: 17 additions & 3 deletions pyamf/remoting/wsgigateway.py
Expand Up @@ -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.
Expand All @@ -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

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 105b902

Please sign in to comment.