« Return to Thread: n00b help

Re: n00b help

by Nick Joyce :: Rate this Message:

Reply to Author | View in Thread

Hi!

On 4 Jul 2009, at 21:47, Jesse Warden wrote:

Just trying to ensure I get it.  Python & Django n00b, ActionScript & Flex veteran.  I managed to get the HelloWorld working in another project & app.  AMF through Django with authentication.... not so much...

It seems if I follow the instructions here:


I just need to have an "amfgateway.py" file in my app folder.  This is basically a FrontController, and from it, I can define functions that my Flex client can call.  Looking at the example on Joel's blog, however, has me confused.  So, bunch of questions:

You don't _need_ to have an amfgateway.py file, it's just a convention. What you do need is a way for Django to map the url to the gateway instance (done in urls.py). 'amfgateway' could be called 'views', 'foo', 'bar' - your choice ..


----------------------------------

How do I wire up my Remoting tag?  Assuming I have this in my amfgateway.py services dict:

services = {
    'cloud.echo': echo
}

And my modified urls.py in the main project has this added:

(r'^gateway/', 'powerz.cloud.amfgateway.echoGateway'),

Then I'd have a RemoteObject tag in Flex like:

<mx:RemoteObject id="remoteObj" destination="powerz.cloud.amfgateway.echoGateway" endpoint="http://localhost:8000">
   <mx:method name="echo" result="onResult(event)" fault="onFault(event)"/>
</mx:RemoteObject>

Right?

Not quite. If you set the endpoint to 'http://localhost:8000/gateway/' and destination to 'cloud' then it should all work as expected. Destination is just a convenient way to add a namespace to the method that you are calling. So if you called remoteObj.echo, Flash sends an POST request to endpoint using a concatenation of destination and the method name ('cloud.echo' in this case - notice how this maps to the services dict in amfgateway.py).

'powerz.cloud.amfgateway.echoGateway' is the fully qualified import name in Python. Nowhere does PyAMF/Django expose this name publicly.


----------------------------------

What is the difference between this:



^-- Is this url correct? It is the source code for DjangoGateway used for PyAMF, not an example.

And the client example here:


Are both just examples to use during development?  What do I actually have to deploy for production?  Are errors from authentication something I can recognize on the Flex client vs. a regular scripting error?

Any exceptions that are raised during the execution of the service method ('cloud.echo' in the example above) will be converted to an ErrorMessage/ErrorFault and returned to the Flash client. Any decoding/encoding errors will cause an HTTP status 500.

Note that PyAMF does not support RemoteObject.setCredentials but as the FP supports session cookies I would suggest doing it that way.


Thanks for your time.



_______________________________________________
PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users

Hope all that makes (some) sense. Any more questions/queries let me know.

Cheers,

Nick

_______________________________________________
PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users

 « Return to Thread: n00b help