mardi 14 juin 2016

Using view context in model's _post_put_hook


I've overridden _post_put_hook() on one of my NDB models and I want to change the way I process my result depending on the URL the original request was made to:

def _post_put_hook(self, future):
    key = future.get_result()
    # Do some processing
    if <model was made thanks to POST call to /foo>:
        # Do one thing
    else:
        # Do another

I know this is kinda ugly and bridges the large chasm between API and underlying DB models, but nonetheless it's what I want to achieve.

I can't seem to think of a good, async-safe way to achieve this. What am I missing?


Aucun commentaire:

Enregistrer un commentaire