Gateway for Gluon web framework

View: New views
2 Messages — Rating Filter:   Alert me  

Gateway for Gluon web framework

by rpb :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi guys! I hope you all had a nice christmas. I am still trying to get
Pyamf to work with Gluon(http://mdp.cti.depaul.edu/). The flash file Im
using works with the WSGI gateway with Pylons.  This is what my code
looks like in Gluon, is there anything tat I did wrong or forgot?

import pyamf
import pyamf.remoting.gateway

### services you want to expose via pyamf gateway...

def echo(data):
  print "this is the echo service"
  return data

services={'echo.echo':echo}

### here is the Gluon gateway should be the equivalent to DjangoGateway

def gateway():
  print "gateway func called"
  base_gateway = pyamf.remoting.gateway.BaseGateway(services)
  context = pyamf.get_context(pyamf.AMF0)
  if not request.body: request.body=request.env.wsgi_input.read()
  pyamf_request = pyamf.remoting.decode(request.body, context)
  pyamf_response = pyamf.remoting.Envelope(pyamf_request.amfVersion, \

pyamf_request.clientType)
  for name, message in pyamf_request:
      pyamf_response[name] = base_gateway.getProcessor(message)(message)
  response.headers['Content-Type'] = pyamf.remoting.CONTENT_TYPE
  return pyamf.remoting.encode(pyamf_response, context).getvalue()


Thanks in advance!


Re: Gateway for Gluon web framework

by Nick Joyce :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hey akira,

The gateway code looks good, but I haven't done any specific testing (I'm
also not that familiar with Gluon). Are there any error messages being
generated by Flash? I would suggest that you use the PyAMF client to
determine what's being sent etc. Also using an http proxy like Charles
(http://www.xk72.com/charles/) to see whats being sent/received comes in
very handy.

Hope this helps.

Cheers,

Nick

On Sun, December 30, 2007 9:17 pm, akira wrote:

> Hi guys! I hope you all had a nice christmas. I am still trying to get
> Pyamf to work with Gluon(http://mdp.cti.depaul.edu/). The flash file Im
> using works with the WSGI gateway with Pylons.  This is what my code looks
> like in Gluon, is there anything tat I did wrong or forgot?
>
> import pyamf import pyamf.remoting.gateway
>
> ### services you want to expose via pyamf gateway...
>
>
> def echo(data): print "this is the echo service" return data
>
> services={'echo.echo':echo}
>
>
> ### here is the Gluon gateway should be the equivalent to DjangoGateway
>
>
> def gateway(): print "gateway func called" base_gateway =
> pyamf.remoting.gateway.BaseGateway(services) context =
> pyamf.get_context(pyamf.AMF0) if not request.body:
> request.body=request.env.wsgi_input.read() pyamf_request =
> pyamf.remoting.decode(request.body, context) pyamf_response =
> pyamf.remoting.Envelope(pyamf_request.amfVersion, \
>
> pyamf_request.clientType) for name, message in pyamf_request:
> pyamf_response[name] = base_gateway.getProcessor(message)(message)
> response.headers['Content-Type'] = pyamf.remoting.CONTENT_TYPE return
> pyamf.remoting.encode(pyamf_response, context).getvalue()
>
>
> Thanks in advance!
> _______________________________________________
> PyAMF dev mailing list - dev@...
> http://lists.pyamf.org/mailman/listinfo/dev
>
>