I am trying to get an event when ever I do a POST request. This is the code:
from eve import Eve
def before_insert(response):
print 'About to return artists'
app = Eve(settings='settings.py')
app.on_insert += before_insert
if __name__ == '__main__':
app.run()
I have no code in the settings file to accommodate the events - just standard stuff that works fine when I remove the line: app.on_insert += before_insert
When I do a POST I get:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>500 Internal Server Error</title>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p>
when I do GET on the resource I get the data but the POST has not been added...
Wassup??
Looks like your callback function has a wrong signature. Try the following.
from eve import Eve
def before_insert(resource_name, items):
print 'About to return artists'
app = Eve(settings='settings.py')
app.on_insert += before_insert
if __name__ == '__main__':
app.run(debug=True)
In any case, try running the app with DEBUG = True
in your settings file, or run it with app.run(debug=True)
, so you can get a hint on what the actual problem is.