开发者

return a FaultObject on purpose from pyamf

I am currently migrating fro开发者_C百科m RubyAMF to PyAMF. In RubyAMF you can return a FaultObject deliberately like so:

render :amf => FaultObject.new("Thats not your pie!")

Is there comparable functionality in PyAMF? I've searched the docs and can't find any mention of it.


coulix is right (but due to reputation restrictions I cannot upvote! :)

From within your service method, raise an exception as you would normally and PyAMF will trap that and convert it to an appropriate fault object for consumption by the requestor (e.g. using Flex Messaging this will be an ErrorMessage instance).

class HandsOffThatPie(Exception):
    pass

def get_pie(please=False):
    if not please:
        raise HandsOffThatPie('Say please!')


raise Exception, "ur message" can do.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜