changeset 288:e6f585ac9766

use teardown_request (teardown_wiki) instead of after_request (after_wiki), because it is called when an exception happened
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 10 Jul 2011 14:13:58 +0200
parents a4461b58fba3
children 1c377ccaf6a1
files MoinMoin/app.py MoinMoin/conftest.py
diffstat 2 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/app.py	Sun Jul 10 13:54:00 2011 +0200
+++ b/MoinMoin/app.py	Sun Jul 10 14:13:58 2011 +0200
@@ -107,19 +107,19 @@
     # register modules, before/after request functions
     from MoinMoin.apps.frontend import frontend
     frontend.before_request(before_wiki)
-    frontend.after_request(after_wiki)
+    frontend.teardown_request(teardown_wiki)
     app.register_blueprint(frontend)
     from MoinMoin.apps.admin import admin
     admin.before_request(before_wiki)
-    admin.after_request(after_wiki)
+    admin.teardown_request(teardown_wiki)
     app.register_blueprint(admin, url_prefix='/+admin')
     from MoinMoin.apps.feed import feed
     feed.before_request(before_wiki)
-    feed.after_request(after_wiki)
+    feed.teardown_request(teardown_wiki)
     app.register_blueprint(feed, url_prefix='/+feed')
     from MoinMoin.apps.misc import misc
     misc.before_request(before_wiki)
-    misc.after_request(after_wiki)
+    misc.teardown_request(teardown_wiki)
     app.register_blueprint(misc, url_prefix='/+misc')
     from MoinMoin.apps.serve import serve
     app.register_blueprint(serve, url_prefix='/+serve')
@@ -294,16 +294,16 @@
     # if return value is not None, it is the final response
 
 
-def after_wiki(response):
+def teardown_wiki(response):
     """
-    Stop timers.
+    Teardown environment of wiki requests, stop timers.
     """
-    logging.debug("running after_wiki")
+    logging.debug("running teardown_wiki")
     try:
         flaskg.clock.stop('total')
         del flaskg.clock
     except AttributeError:
-        # can happen if after_wiki() is called twice, e.g. by unit tests.
+        # can happen if teardown_wiki() is called twice, e.g. by unit tests.
         pass
     return response
 
--- a/MoinMoin/conftest.py	Sun Jul 10 13:54:00 2011 +0200
+++ b/MoinMoin/conftest.py	Sun Jul 10 14:13:58 2011 +0200
@@ -30,7 +30,7 @@
 
 import py
 
-from MoinMoin.app import create_app_ext, destroy_app, before_wiki, after_wiki
+from MoinMoin.app import create_app_ext, destroy_app, before_wiki, teardown_wiki
 from MoinMoin._tests import maketestwiki, wikiconfig
 from MoinMoin.storage.backends import create_simple_mapping
 
@@ -79,7 +79,7 @@
     return app, ctx
 
 def deinit_test_app(app, ctx):
-    after_wiki('')
+    teardown_wiki('')
     ctx.pop()
     destroy_app(app)