views:

98

answers:

2

I am currently migrating from 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.

A: 

raise Exception, "ur message" can do.

coulix
A: 

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!')
njoyce