[prev in list] [next in list] [prev in thread] [next in thread]
List: pyamf-users
Subject: [pyamf-users] Exposing a class from twisted Python to Flex
From: lists () collab ! nl (Thijs Triemstra | Collab)
Date: 2008-05-05 9:42:10
Message-ID: 9437BA4F-88E0-472B-B88F-B06524FB6150 () collab ! nl
[Download RAW message or body]
Hi Bruce, that's one of the best articles / howtos for Twisted/PyAMF
I've seen so far, thanks! You should consider sending it to Adobe's
Devnet! :)
Cheers,
Thijs
On 3 mei 2008, at 20:15, Bruce Eckel wrote:
> I just put up the article:
> http://www.artima.com/weblogs/viewpost.jsp?thread=230001
>
> Thanks much for your help on this.
>
> On Wed, Apr 30, 2008 at 11:32 AM, Bruce Eckel
> <mindviewinc at gmail.com> wrote:
>> I'll put in a note to use PyAMF 0.3.1, and it's doubtful I'll finish
>> the article before you put up that release.
>>
>> Thanks again for the help.
>>
>>
>>
>> On Wed, Apr 30, 2008 at 9:12 AM, Nick Joyce <nick at boxdesign.co.uk>
>> wrote:
>>> The patch will be merged to trunk after we iterate through the
>>> combinations
>>> of RemoteObject configurations and update the unit tests
>>> accordingly. The
>>> plan is for PyAMF 0.3.1 to be released within the next 24 hrs so
>>> if you
>>> could hold off your post until then, that would be great. We would
>>> rather
>>> not have users having to patch their install :)
>>>
>>> Cheers,
>>>
>>> Nick
>>>
>>>
>>>
>>>
>>> On 30 Apr 2008, at 15:32, Bruce Eckel wrote:
>>> FYI: I put in the patch and it does indeed work with my code.
>>> Thanks.
>>>
>>> On Wed, Apr 30, 2008 at 6:32 AM, Bruce Eckel
>>> <mindviewinc at gmail.com> wrote:
>>> Thanks, Nick. From the ticket, it looks like this patch has been
>>> accepted into the next revision -- is that correct? I guess I can
>>> just
>>> publish the link to the patch when I put the article out.
>>>
>>>
>>>
>>> On Wed, Apr 30, 2008 at 12:51 AM, Nick Joyce
>>> <nick at boxdesign.co.uk> wrote:
>>>
>>> Hi,
>>>
>>>
>>>
>>> I've checked the python code using the PyAMF client:
>>>
>>>
>>>
>>>
>>>
>>> from pyamf.remoting.client import RemotingService
>>>
>>>
>>>
>>> gw = RemotingService('http://localhost:8050/')
>>>
>>> service = gw.getService('master')
>>>
>>>
>>>
>>> print service.Start()
>>>
>>>
>>>
>>> That works as expected, but using the mxml you provided doesn't.
>>> Turns out
>>>
>>> that CommandMessage being sent from the Flash Player is not being
>>>
>>> interpreted correctly by PyAMF's service mapping code. A
>>> combination of the
>>>
>>> destination and operation attributes give the complete service
>>> method
>>>
>>> (whereas PyAMF was just using operation).
>>>
>>>
>>>
>>> There are two solutions here, use the remoting-config.xml as Adobe
>>> suggests
>>>
>>> or apply the attached patch that makes PyAMF work for this
>>> specific problem.
>>>
>>> I haven't tested other combinations of source/destination etc. but
>>> I have
>>>
>>> created a ticket to track this issue [1].
>>>
>>>
>>>
>>> Cheers,
>>>
>>>
>>>
>>> Nick
>>>
>>>
>>>
>>> [1] http://pyamf.org/ticket/270
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> On 29 Apr 2008, at 23:54, Bruce Eckel wrote:
>>>
>>> Hi, I'm working on a weblog article that uses the twisted pyamf
>>> tool,
>>>
>>> and I can successfully expose standalone functions but not a class
>>> --
>>>
>>> or perhaps I'm exposing the class correctly but I'm not calling it
>>>
>>> correctly from Flex.
>>>
>>>
>>>
>>> Any help is appreciated.
>>>
>>>
>>>
>>> Here's the Python code (note that I'm flailing about here so some
>>>
>>> things may be obviously wrong):
>>>
>>>
>>>
>>> class FlexInterface(pb.Root):
>>>
>>>
>>>
>>> def Start(self, _):
>>>
>>> return "Starting parallel jobs"
>>>
>>>
>>>
>>> def Terminate(self, _):
>>>
>>> return "Terminating remote solvers"
>>>
>>>
>>>
>>>
>>>
>>> if __name__ == "__main__":
>>>
>>>
>>>
>>> # Place the namespace mapping into a TwistedGateway
>>>
>>> gateway = TwistedGateway({ "master": FlexInterface() })
>>>
>>> # A base root resource for the twisted.web server
>>>
>>> root = resource.Resource()
>>>
>>> # Publish the PyAMF gateway at the root URL
>>>
>>> root.putChild("", gateway)
>>>
>>> # Tell the twisted reactor to listen
>>>
>>> reactor.listenTCP(8050, server.Site(root))
>>>
>>>
>>>
>>> # One reactor runs all servers and clients
>>>
>>> reactor.run()
>>>
>>>
>>>
>>> Here's the MXML:
>>>
>>>
>>>
>>> <?xml version="1.0" encoding="utf-8"?>
>>>
>>> <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
>>>
>>> horizontalAlign="left">
>>>
>>> <mx:RemoteObject id="remoteObj" endpoint="http://localhost:8050"
>>>
>>> destination="master"
>>>
>>> result="display(event)" fault="display(event)"/>
>>>
>>> <mx:Button label="Start" click="remoteObj.Start()" />
>>>
>>> <mx:Button label="Terminate" click="remoteObj.Terminate()" />
>>>
>>> <mx:TextArea id="output" width="100%" height="100%"/>
>>>
>>> <mx:Script>
>>>
>>> <![CDATA[
>>>
>>> private function display(result:*): void {
>>>
>>> output.text += result.message.body + "\n"
>>>
>>> output.text += result.toString() + "\n"
>>>
>>> }
>>>
>>> ]]>
>>>
>>> </mx:Script>
>>>
>>> </mx:WindowedApplication>
>>>
>>>
>>>
>>>
>>>
>>> --
>>>
>>> Bruce Eckel
>>>
>>>
>>>
>>> _______________________________________________
>>>
>>> PyAMF users mailing list - users at pyamf.org
>>>
>>> http://lists.pyamf.org/mailman/listinfo/users
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>>
>>> PyAMF users mailing list - users at pyamf.org
>>>
>>> http://lists.pyamf.org/mailman/listinfo/users
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> --
>>> Bruce Eckel
>>> Keep up on new developments with the newsletter:
>>> http://www.mindview.net/Newsletter
>>>
>>>
>>>
>>>
>>> --
>>> Bruce Eckel
>>> Keep up on new developments with the newsletter:
>>> http://www.mindview.net/Newsletter
>>> _______________________________________________
>>> PyAMF users mailing list - users at pyamf.org
>>> http://lists.pyamf.org/mailman/listinfo/users
>>>
>>>
>>> _______________________________________________
>>> PyAMF users mailing list - users at pyamf.org
>>> http://lists.pyamf.org/mailman/listinfo/users
>>>
>>>
>>
>>
>>
>> --
>> Bruce Eckel
>> Keep up on new developments with the newsletter:
>> http://www.mindview.net/Newsletter
>>
>
>
>
> --
> Bruce Eckel
> Keep up on new developments with the newsletter:
> http://www.mindview.net/Newsletter
> _______________________________________________
> PyAMF users mailing list - users at pyamf.org
> http://lists.pyamf.org/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.pyamf.org/pipermail/users/attachments/20080505/f58c684e/attachment-0001.htm
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 194 bytes
Desc: This is a digitally signed message part
Url : http://lists.pyamf.org/pipermail/users/attachments/20080505/f58c684e/attachment-0001.pgp
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic