0

I am trying to use a preprocessor in Flask-Restless to check for a condition and if the condition is met to interrupt the PUT statement and not update the database. I've tried to del or empty the data dict but that does not seem to be working:

def pre_post(data=None, **kw):
if data['thought'] == 'test':
    data.clear()
    # Don't add to database

Doing this just adds a null to the databae

RedRaven
  • 725
  • 2
  • 18
  • 33
  • Raising a `ValidationError` or something similar is almost certainly what you need to do here :-) – Sean Vieira May 31 '14 at 02:09
  • Not quite, I am breaking up the data and inserting into different tables within the function. I want to get rid of the original `data` so I don't end up with an extra row in my database. – RedRaven May 31 '14 at 02:15
  • So you are using the `pre_*` function as a routing function to determine whether to update one entity or a set of related entities? – Sean Vieira May 31 '14 at 02:45
  • yep, not sure it's right... but this is my first try with Flask-Restless – RedRaven May 31 '14 at 02:48
  • Can you give a bit more of an example? What kind of entity are you taking in, and under what circumstances would you break it up? – Sean Vieira May 31 '14 at 03:03
  • I ended up doing this differently, but to answer my own question the command I was looking for was simply `abort`. Should've read the docs more closely... – RedRaven May 31 '14 at 22:10

0 Answers0