dino
dino

Reputation: 3307

unable to trigger flask restless postprocessor

I'm using Flask-Restless 0.17.0 and having trouble getting a preprocessor or postprocessor function to fire. For reference, I have an SQLAlchemy model that look like:

class Transaction(Base):
    id = Column(Integer, primary_key=True)
    name = Column(Unicode)
    description = Column(Unicode)

I'm able to register the API endpoint without any trouble, but I can not get this hello_world postprocessor to print "hello world" for the life of me:

def hello_world(**kwargs):
    print 'hello world'

manager.create_api(
    fraud.data.Transaction
    methods=['GET', 'POST', 'DELETE'],
    postprocessors={'POST_RESOURCE': [hello_world]},
)

Am I missing something? Any pointers, hints, etc would be greatly appreciated!

Upvotes: 1

Views: 496

Answers (1)

Robᵩ
Robᵩ

Reputation: 168616

Version 0.17.0 doesn't support POST_RESOURCE. The supported post-processor types appear to be:

  • 'GET_SINGLE' for requests to get a single instance of the model.
  • 'GET_MANY' for requests to get the entire collection of instances of the * model.
  • 'PATCH_SINGLE' or'PUT_SINGLE'` for requests to patch a single instance of the model.
  • 'PATCH_MANY' or 'PATCH_SINGLE' for requests to patch the entire collection of instances of the model.
  • 'POST' for requests to post a new instance of the model.
  • 'DELETE_SINGLE'
  • 'DELETE_MANY'

For your usage, try postprocessors={'POST': [hello_world]}.

References:

Upvotes: 4

Related Questions