flex3, amfrpc and gae

4 views
Skip to first unread message

Dave

unread,
Apr 20, 2009, 11:38:23 PM4/20/09
to web2py Web Framework
Hello,

I've written a small flex client to test my amfrpc service. It works
fine in web2py, but not in gae.

The gae log shows
INFO 2009-04-21 03:24:55,043 dev_appserver.py] "POST /cuecut/
projects/call/amfrpc HTTP/1.1" 200 -

which seems normal, but my function is not firing. Could someone
verify? After running the flex app and Create Project form will
display with 5 fields. Just click submit to verify that it contacts
the service and calls function f(a,b,c). It should just concatenate
the hardcoded values and return <project_id>onetwothree</project_id>

Thanks!
-Dave

My controller function:
@service.amfrpc
# usage: projects/call/xml/f/a/b/c
def f(a,b,c):
print a, b, c
return a+b+c

My mxml code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
horizontalAlign="center" verticalAlign="middle"
backgroundColor="#FFFFFF" backgroundAlpha="0">

<mx:Form label="Login">

<mx:FormItem label="Create Project"/>
<mx:FormItem label="name:">
<mx:TextInput id="name_txt"/>
</mx:FormItem>
<mx:FormItem label="description:">
<mx:TextInput id="description_txt"/>
</mx:FormItem>
<mx:FormItem label="summary:">
<mx:TextInput id="summary_txt"/>
</mx:FormItem>
<mx:FormItem label="type:">
<mx:TextInput id="type_txt"/>
</mx:FormItem>
<mx:FormItem label="owner_id:">
<mx:TextInput id="owner_id_txt"/>
</mx:FormItem>

<mx:FormItem horizontalAlign="right" paddingBottom="10">
<mx:Button label="Submit" click="submit(event)"/>
</mx:FormItem>

<mx:Text id="status_txt" textAlign="center" fontWeight="bold"
width="250" height="100"/>
</mx:Form>


<mx:Script>
<![CDATA[
import flash.net.NetConnection;
import flash.net.Responder;

// Gateway connection object
private var gateway:NetConnection;

// submit action
public function submit( event:MouseEvent ): void
{
var name:String = name_txt.text;
var description:String = description_txt.text;
var summary:String = summary_txt.text;
var type:String = type_txt.text;
var owner_id:String = owner_id_txt.text;

// Setup connection
gateway = new NetConnection();

// Connect to gateway
gateway.connect( "http://localhost:8000/app/controller/
call/amfrpc");

// Set responder property to the object and methods that
will receive the
// result or fault condition that the service returns.
var responder:Responder = new Responder( onResult,
onFault );

// Call remote service.method: call(function. responder,
param1, param2)
gateway.call( "f", responder, 'one', 'two', 'three' );

}

// Result handler method
private function onResult( result:* ): void
{
var myData:String = result;
trace( myData );
status_txt.text = "Success: data = " + myData;
}

// Fault handler method displays error message
private function onFault( error:* ): void
{
// Notify the user of the problem
status_txt.text = "Remoting error:";
for ( var d:String in error ) {
status_txt.text += error[d] + "\n";
}
}
]]>
</mx:Script>


</mx:Application>

mdipierro

unread,
Apr 20, 2009, 11:42:04 PM4/20/09
to web2py Web Framework
Because when serving and amf request web2py does:

try:
import pyamf
import pyamf.remoting.gateway
except:
return "pyamf not installed or not in Python sys.path"

So if pyamf is not in the path it returns 200 OK with the string
"pyamf not installed or not in Python sys.path".
I do not know if pyamf can be deployed on GAE. If it is pure python it
can, else it cannot.

Massimo

Dave

unread,
Apr 21, 2009, 1:21:55 AM4/21/09
to web2py Web Framework
Thanks. (my bad). I installed pyamf and now I'm getting 303 instead of
200. Some progress ;) Pyamf does support GAE. (http://pyamf.org/wiki/
GoogleAppEngine).
I guess the issue is getting it to work with web2py. With
dev_appserver.py and debug on, I run a python client and I'm seeing:

>>> print service.echo('hello world')
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Users/dfdumaresq/Projects/workspace_34/web2py_159/pyamf/
remoting/client/__init__.py", line 52, in __call__
return self.service._call(self, *args)
File "/Users/dfdumaresq/Projects/workspace_34/web2py_159/pyamf/
remoting/client/__init__.py", line 101, in _call
response = self._gw.execute_single(request)
File "/Users/dfdumaresq/Projects/workspace_34/web2py_159/pyamf/
remoting/client/__init__.py", line 409, in execute_single
envelope = self._getResponse()
File "/Users/dfdumaresq/Projects/workspace_34/web2py_159/pyamf/
remoting/client/__init__.py", line 454, in _getResponse
http_response.status, httplib.responses[http_response.status]))
RemotingError: HTTP Gateway reported status 303 See Other

The dev_appserver.py output is:

DEBUG 2009-04-21 05:09:54,587 dev_appserver.py] Matched "/" to CGI
dispatcher with path gaehandler.py
DEBUG 2009-04-21 05:09:54,590 dev_appserver.py] Executing CGI with
env:
{'APPLICATION_ID': 'cuecut',
'AUTH_DOMAIN': 'gmail.com',
'CONTENT_LENGTH': '49',
'CONTENT_TYPE': 'application/x-amf',
'CURRENT_VERSION_ID': '1.1',
'GATEWAY_INTERFACE': 'CGI/1.1',
'HTTP_HOST': 'localhost:8000',
'HTTP_USER_AGENT': 'PyAMF/0.4.1',
'PATH_INFO': '/',
'PATH_TRANSLATED': '/Users/dfdumaresq/Projects/workspace_34/
web2py_159/gaehandler.py',
'QUERY_STRING': '',
'REMOTE_ADDR': '127.0.0.1',
'REQUEST_METHOD': 'POST',
'SCRIPT_NAME': '',
'SERVER_NAME': 'localhost',
'SERVER_PORT': '8000',
'SERVER_PROTOCOL': 'HTTP/1.0',
'SERVER_SOFTWARE': 'Development/1.0',
'TZ': 'UTC',
'USER_EMAIL': ''}
DEBUG 2009-04-21 05:09:54,590 dev_appserver.py] Reusing main()
function of module "gaehandler"
WARNING 2009-04-21 05:09:54,591 cache.py] no cache.disk
INFO 2009-04-21 05:09:54,623 dev_appserver.py] "POST / HTTP/1.1"
303 -
DEBUG 2009-04-21 05:09:54,624 dev_appserver_index.py] No need to
update index.yaml

All I can come up with here is perhaps gaehandler cannot find the
service echo, which is in /cuecut/projects.

Thanks for any ideas.
Dave
Reply all
Reply to author
Forward
0 new messages