Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Application processors

  • Loading branch information...
commit 573121f3ac0214f98d33fc95f4b27e401529cf69 1 parent 8bdb817
@anandology anandology authored
Showing with 36 additions and 0 deletions.
  1. +36 −0 cookbook/application_processors.md
View
36 cookbook/application_processors.md
@@ -0,0 +1,36 @@
+---
+layout: default
+title: Application processors
+---
+
+# Application processors
+
+## Problem
+
+How to use application processors, loadhooks and unload hooks?
+
+## Solution
+
+web.py application allows adding processors which can do some processing before and after executing the requests
+
+ def my_processor(handler):
+ print 'before handling'
+ result = handler()
+ print 'after handling'
+ return result
+
+ app.add_processor(my_processor)
+
+Load hooks and unload hooks can be used to do actions at begining and end of requests.
+
+ def my_loadhook():
+ print "my load hook"
+
+ def my_unloadhook():
+ print "my unload hook"
+
+ app.add_procerssor(web.loadhook(my_loadhook))
+ app.add_procerssor(web.unloadhook(my_unloadhook))
+
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.