added uwsgi.after_req_hook

This commit is contained in:
roberto@oneiric64
2012-01-10 20:30:46 +01:00
parent 4c82a72fd5
commit db301531d0
4 changed files with 28 additions and 0 deletions
+10
View File
@@ -1053,6 +1053,16 @@ void uwsgi_python_init_apps() {
#endif
}
PyObject *uwsgi_dict = get_uwsgi_pydict("uwsgi");
if (uwsgi_dict) {
up.after_req_hook = PyDict_GetItemString(uwsgi_dict, "after_req_hook");
if (up.after_req_hook) {
Py_INCREF(up.after_req_hook);
up.after_req_hook_args = PyTuple_New(0);
Py_INCREF(up.after_req_hook_args);
}
}
}
void uwsgi_python_master_fixup(int step) {
+3
View File
@@ -186,6 +186,9 @@ struct uwsgi_python {
int reload_os_env;
PyObject *after_req_hook;
PyObject *after_req_hook_args;
};
+11
View File
@@ -513,6 +513,17 @@ clear2:
void uwsgi_after_request_wsgi(struct wsgi_request *wsgi_req) {
if (up.after_req_hook) {
PyObject *arh = python_call(up.after_req_hook, up.after_req_hook_args, 0, NULL);
if (!arh) {
PyErr_Print();
}
else {
Py_DECREF(arh);
}
PyErr_Clear();
}
if (uwsgi.shared->options[UWSGI_OPTION_LOGGING] || wsgi_req->log_this) {
log_request(wsgi_req);
}