One more test. delete all tickets (errors/*) and see if a new tickets
is generated by the flash request. It may contain some useful info.

massimo

On Mar 9, 3:39 pm, Igor Gassko <[email protected]> wrote:
> I embedded it right into the library.zip of web2py by openning .egg
> package and using its pyamf folder. I'm quite sure that pyamf is being
> imported, because before I did this trick I was getting "no module
> named pyamf" error. I also tried using the source version (by
> appending it directly to app.path) with the same result.
> The problem is that I don't know how to debug this scenario, the
> browser shows error, apparently because the request lacks some stuff.
>
> On Mar 9, 11:28 pm, mdipierro <[email protected]> wrote:
>
> > not sure but:
> > 1) let's concentrate on the first method since that is the new way of
> > handling this
> > 2) you appear to be using the windows binary distribution of web2py.
> > that does not come with pyamf and would not see it even if installed.
> > Could that be the problem? Could you try using the source version. You
> > would need to install pyamf separately.
>
> > On Mar 9, 1:04 pm, iggass <[email protected]> wrote:
>
> > > Hello!
>
> > > I'm trying to deploy basic connectivity between Flex AS3 application
> > > and web2py server-side. In order to achieve this noble cause I studied
> > > the official tutorial (http://www.web2py.com/AlterEgo/default/show/22)
> > > and the official documentation (http://web2py.com/book/default/section/
> > > 9/2).
> > > So, I created two controllers 'rpc' and 'rpc2' as follows:
>
> > > rpc.py
> > > ---------------
> > > from gluon.tools import Service
> > > service = Service(globals())
>
> > > def call():
> > >     session.forget()
> > >     return service()
>
> > > @service.amfrpc
> > > def test():
> > >     return "Test!!!"
>
> > > rpc2.py
> > > ---------------
> > > import pyamf
> > > import pyamf.remoting.gateway
>
> > > def test():
> > >     return "Test!!!"
>
> > > services={'test.test':test}
>
> > > def gateway():
> > >     base_gateway = pyamf.remoting.gateway.BaseGateway(services)
> > >     context = pyamf.get_context(pyamf.AMF0)
> > >     pyamf_request = pyamf.remoting.decode(request.body.read(),
> > > 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()
>
> > > -------------
>
> > > After that, I tried accessing exposed amf services using both
> > > controllers respectively via browser through the following URLs:
>
> > >http://127.0.0.1:8000/AppTryout/rpc/call/amfrpc/testhttp://127.0.0.1:...
>
> > > In both cases I recieve similar errors:
>
> > > forhttp://127.0.0.1:8000/AppTryout/rpc/call/amfrpc/test:
> > > ---------------------------------------------------------------------------
> > >  ------
> > > Traceback (most recent call last):
> > >   File "gluon/restricted.py", line 173, in restricted
> > >   File "//server2003/web2py/applications/AppTryout/controllers/
> > > rpc.py", line 13, in <module>
> > >   File "gluon/globals.py", line 96, in <lambda>
> > >   File "//server2003/web2py/applications/AppTryout/controllers/
> > > rpc.py", line 7, in call
> > >   File "gluon/tools.py", line 2942, in __call__
> > >   File "gluon/tools.py", line 2885, in serve_amfrpc
> > >   File "\\server2003\web2py\library.zip\pyamf\remoting\__init__.py",
> > > line 634, in decode
> > >   File "\\server2003\web2py\library.zip\pyamf\util\__init__.py", line
> > > 322, in read_uchar
> > >   File "\\server2003\web2py\library.zip\pyamf\util\__init__.py", line
> > > 298, in _read
> > >   File "\\server2003\web2py\library.zip\pyamf\util\__init__.py", line
> > > 646, in read
> > > IOError: Attempted to read 1 bytes from the buffer but only 0 remain
>
> > > In file: \\server2003\web2py\applications\AppTryout/controllers/rpc.py
> > > from gluon.tools import Service
> > > service = Service(globals())
>
> > > def call():
> > >     session.forget()
> > >     return service()
>
> > > @service.amfrpc
> > > def test():
> > >     return "Test!!!"
>
> > > response._vars=response._caller(call)
>
> > > forhttp://127.0.0.1:8000/AppTryout/rpc/call/amfrpc/test:
> > > ---------------------------------------------------------------------------
> > >  ------
> > > Traceback (most recent call last):
> > >   File "gluon/restricted.py", line 173, in restricted
> > >   File "//server2003/web2py/applications/AppTryout/controllers/
> > > rpc2.py", line 18, in <module>
> > >   File "gluon/globals.py", line 96, in <lambda>
> > >   File "//server2003/web2py/applications/AppTryout/controllers/
> > > rpc2.py", line 12, in gateway
> > >   File "\\server2003\web2py\library.zip\pyamf\remoting\__init__.py",
> > > line 634, in decode
> > >   File "\\server2003\web2py\library.zip\pyamf\util\__init__.py", line
> > > 322, in read_uchar
> > >   File "\\server2003\web2py\library.zip\pyamf\util\__init__.py", line
> > > 298, in _read
> > >   File "\\server2003\web2py\library.zip\pyamf\util\__init__.py", line
> > > 646, in read
> > > IOError: Attempted to read 1 bytes from the buffer but only 0 remain
>
> > > In file: \\server2003\web2py\applications\AppTryout/controllers/
> > > rpc2.py
> > > import pyamf
> > > import pyamf.remoting.gateway
>
> > > def test():
> > >     return "Test!!!"
>
> > > services={'test.test':test}
>
> > > def gateway():
> > >     base_gateway = pyamf.remoting.gateway.BaseGateway(services)
> > >     context = pyamf.get_context(pyamf.AMF0)
> > >     pyamf_request = pyamf.remoting.decode(request.body.read(),
> > > 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()
> > > response._vars=response._caller(gateway)
>
> > > It can be seen that in both cases the error arrises in the statement:
> > > response._vars=response._caller(...)
> > > and involves exactly the same code in pyamf module.
>
> > > In httpserver.log I get:
> > > 127.0.0.1, 2010-03-09 20:49:52, GET, /AppTryout/rpc/call/amfrpc/test,
> > > HTTP/1.1, 500, 4.131000
> > > 127.0.0.1, 2010-03-09 20:50:24, GET, /AppTryout/rpc2/gateway/test,
> > > HTTP/1.1, 500, 6.098000
>
> > > ---------------------------------------------------------------------------
> > >  --
>
> > > My surmise is thay amfrpc won't work with browser, so I prepared
> > > simple Flex application to consume these services:
>
> > > <?xml version="1.0" encoding="utf-8"?>
> > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
> > > layout="absolute">
> > >         <mx:Script>
> > >                 <![CDATA[
> > >                         import mx.rpc.events.FaultEvent;
> > >             import mx.rpc.events.ResultEvent;
> > >             import mx.controls.Alert;
>
> > >             private function resultHandler(event:ResultEvent):void
> > >             {
> > >                 trace(event.result.toString());
> > >             }
>
> > >             private function faultHandler(event:FaultEvent):void
> > >             {
> > >                 trace(event.fault.message);
> > >             }
>
> > >             private function fire():void
> > >             {
> > >                 amfService.test();
> > >                 amfService2.test();
> > >             }
> > >                 ]]>
> > >         </mx:Script>
>
> > >     <mx:RemoteObject id="amfService" showBusyCursor="true"
> > > destination="dest-amfrpc">
> > >          <mx:method name="test" result="resultHandler(event)"
> > > fault="faultHandler(event)"/>
> > >     </mx:RemoteObject>
> > >     <mx:RemoteObject id="amfService2" showBusyCursor="true"
> > > destination="dest-amfrpc2">
> > >          <mx:method name="test" result="resultHandler(event)"
> > > fault="faultHandler(event)"/>
> > >     </mx:RemoteObject>
> > >     <mx:Button x="250" y="150" label="Fire" click="fire();"/>
> > > </mx:Application>
>
> > > ------------
>
> > > Its corresponding services-config.xml looks as follows:
>
> > > <?xml version="1.0" encoding="UTF-8"?>
> > > <services-config>
> > >   <services>
> > >     <service id="amfrpc-flashremoting-service"
> > >                  class="flex.messaging.services.RemotingService"
>
> > > messageTypes="flex.messaging.messages.RemotingMessage">
> > >             <destination id="dest-amfrpc">
> > >                 <channels>
> > >                     <channel ref="ch-amfrpc"/>
> > >                 </channels>
> > >                 <properties>
> > >                     <source>*</source>
> > >                 </properties>
> > >             </destination>
> > >             <destination id="dest-amfrpc2">
> > >                 <channels>
> > >                     <channel ref="ch-amfrpc2"/>
> > >                 </channels>
> > >                 <properties>
> > >                     <source>*</source>
> > >                 </properties>
> > >             </destination>
> > >         </service>
> > >     </services>
>
> > >     <channels>
> > >         <channel-definition id="ch-amfrpc"
> > > class="mx.messaging.channels.AMFChannel">
> > >             <endpoint uri="http://127.0.0.1:8000/AppTryout/rpc/call/
> > > amfrpc/test" class="flex.messaging.endpoints.AMFEndpoint"/>
> > >         </channel-definition>
> > >         <channel-definition id="ch-amfrpc2"
> > > class="mx.messaging.channels.AMFChannel">
> > >             <endpoint uri="http://127.0.0.1:8000/AppTryout/rpc2/
> > > gateway/test" class="flex.messaging.endpoints.AMFEndpoint"/>
> > >         </channel-definition>
> > >     </channels>
> > > </services-config>
>
> > > -------
>
> > > When I run the Flex app, I got the follwing trace:
>
> > > faultCode:Service.ResourceNotFound faultString:'Unknown service dest-
> > > amfrpc.test' faultDetail:''
>
> ...
>
> read more »

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.

Reply via email to