Permalink
Browse files

Update application_processors.zh-cn.md

  • Loading branch information...
1 parent 5be6b5c commit 8fe8f6eaf197803259195ec3043366dd9e409274 @leiqin leiqin committed Dec 12, 2012
Showing with 14 additions and 1 deletion.
  1. +14 −1 cookbook/application_processors.zh-cn.md
@@ -30,4 +30,17 @@ web.py可以在处理请求之前或之后,通过添加处理器(processor)来
print "my unload hook"
app.add_processor(web.loadhook(my_loadhook))
- app.add_processor(web.unloadhook(my_unloadhook))
+ app.add_processor(web.unloadhook(my_unloadhook))
+
+你可以在钩子中使用和修改全局变量,比如:web.header()
+
+ def my_loadhook():
+ web.header('Content-type', "text/html; charset=utf-8")
+
+ app.add_processor(web.loadhook(my_loadhook))
+
+###提示: 你也可以在钩子中使用 web.ctx 和 web.input() 。
+
+ def my_loadhook():
+ input = web.input()
+ print input

0 comments on commit 8fe8f6e

Please sign in to comment.