« Return to Thread: PyAMF Pylons Question

Re: PyAMF Pylons Question

by snorkel :: Rate this Message:

Reply to Author | View in Thread

Nick Joyce wrote:

> Hi,
>
> If you add expose_request=True to the gateway object, then all calls
> to service methods will have the request object as the first argument.
>
> Hth,
>
> Nick
>
> On 28 May 2009, at 03:51, Tony Caduto wrote:
>

Hi Nick,

I tried the code below, but it errors out.
It does not like the request.environ part.

(<type 'exceptions.AttributeError'>, AttributeError("'dict' object has
no attrib
ute 'environ'",), <traceback object at 0x03806468>)

from flex_gateway.lib import helpers as h

def login(request,username,password):
    try:
        remote_addr = request.environ["REMOTE_ADDR"]
        return username,password,remote_addr
    except:
        print sys.exc_info()
 

def echo(data):
   # echo data back to the client
   return data

def sum(a, b):
    return a + b

def scramble(text):
    from random import shuffle
    s = [x for x in text]
    shuffle(s)
    return ''.join(s)


services = {
    'services.echo': echo,
    'services.sum': sum,
    'services.scramble': scramble,
    'services.login':login
}
GatewayController = h.WSGIGateway(services,expose_request=True)
_______________________________________________
PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users

 « Return to Thread: PyAMF Pylons Question