« Return to Thread: Custom HTTP response

Re: Custom HTTP response

by vitaly-18 :: Rate this Message:

Reply to Author | View in Thread

This is it! Thank you a lot.

Quoting "Nick Joyce" <nick@...>:

> Just do
>
> raise Exception("Session expired")
>
> And PyAMF will do the right thing and convert the exception into a
> ErrorFault object.
>
> Try that :)
>
> On 17 Jun 2009, at 20:26, vitaly@... wrote:
>
>> Thank you for reply.
>> I've raised the exception like:
>>      try:
>>           raise Exception("Session expired")
>>       except Exception:
>>           return Exception
>>
>> But pyAMF caught my exception like:
>>
>> 2009-06-17 15:21:13,672 DEBUG  
>> [pyamf.remoting.gateway.twisted.TwistedGateway.0x2211750] AMF  
>> Response: <Response status=/onResult><AcknowledgeMessage    
>> body=<type 'exceptions.Exception'> timestamp=1245266473  
>> destination=None clientId='cdfc3d99-7fe2-4017-a2c0-07ed13776e5c'  
>> headers={} timeToLive=0  
>> messageId='386a143f-72f3-4687-8f36-a6800dcd914c'  
>> correlationId=u'85C5E409-974F-1AA9-86A6-F0517212A761' /></Response>
>> 2009-06-17 15:21:13,678 ERROR  
>> [pyamf.remoting.gateway.twisted.TwistedGateway.0x2211750] <class  
>> 'pyamf.EncodeError'>: Callables cannot be serialised
>>
>>
>> Where am I wrong ?
>> Appreciate y help.
>>
>>
>>
>>
>>
>> Quoting "Nick Joyce" <nick@...>:
>>
>>> If you want to return an error in remoting, just raise an exception.
>>> The message of the exception will be the description in the error
>>> response.
>>>
>>> Hope that helps.
>>>
>>> Nick
>>>
>>> On 16 Jun 2009, at 19:37, vitaly@... wrote:
>>>
>>>> hi all,
>>>> 1.is there any possibility to send( and how :-)) ) custom HTTP    
>>>> response back to client request?
>>>> Something like:
>>>> return(remote.Response(response, status=remoting.STATUS_ERROR))
>>>>
>>>> 2.how can I set the custom response to some particular HTTP code  
>>>>  and message(body)?
>>>>
>>>> Appreciate the help.
>>>>
>>>> _______________________________________________
>>>> PyAMF users mailing list - users@...
>>>> http://lists.pyamf.org/mailman/listinfo/users
>>>
>>> _______________________________________________
>>> PyAMF users mailing list - users@...
>>> http://lists.pyamf.org/mailman/listinfo/users
>>>
>>
>>
>> _______________________________________________
>> PyAMF users mailing list - users@...
>> http://lists.pyamf.org/mailman/listinfo/users
>
> _______________________________________________
> PyAMF users mailing list - users@...
> http://lists.pyamf.org/mailman/listinfo/users
>


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

 « Return to Thread: Custom HTTP response