comparison MoinMoin/app.py @ 950:57ac61f78053

MoinMoin.app: remove unneeded imports, cosmetic changes
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 09 Oct 2011 16:07:11 +0200
parents 10a358208aba
children a4d4c74721bc
comparison
equal deleted inserted replaced
949:c93f5999c08e 950:57ac61f78053
10 Use create_app(config) to create the WSGI application (using Flask). 10 Use create_app(config) to create the WSGI application (using Flask).
11 """ 11 """
12 12
13 from __future__ import absolute_import, division 13 from __future__ import absolute_import, division
14 14
15 import os
16
17 # do this early, but not in MoinMoin/__init__.py because we need to be able to 15 # do this early, but not in MoinMoin/__init__.py because we need to be able to
18 # "import MoinMoin" from setup.py even before flask, werkzeug, ... is installed. 16 # "import MoinMoin" from setup.py even before flask, werkzeug, ... is installed.
19 from MoinMoin.util import monkeypatch 17 from MoinMoin.util import monkeypatch
20 18
21 from flask import Flask, request, session 19 from flask import Flask, request, session
22 from flask import current_app as app 20 from flask import current_app as app
23 from flask import g as flaskg 21 from flask import g as flaskg
24 22
25 from flaskext.cache import Cache 23 from flaskext.cache import Cache
26 from flaskext.themes import setup_themes 24 from flaskext.themes import setup_themes
27
28 from werkzeug.exceptions import HTTPException
29 25
30 from jinja2 import ChoiceLoader, FileSystemLoader 26 from jinja2 import ChoiceLoader, FileSystemLoader
31 27
32 from MoinMoin import log 28 from MoinMoin import log
33 logging = log.getLogger(__name__) 29 logging = log.getLogger(__name__)
150 clock.stop('create_app flask-themes') 146 clock.stop('create_app flask-themes')
151 clock.stop('create_app total') 147 clock.stop('create_app total')
152 del clock 148 del clock
153 return app 149 return app
154 150
151
155 def destroy_app(app): 152 def destroy_app(app):
156 deinit_backends(app) 153 deinit_backends(app)
157 154
158 155
159 from MoinMoin.storage.middleware import protecting, indexing, routing 156 from MoinMoin.storage.middleware import protecting, indexing, routing
177 acl_rights_contents=app.cfg.acl_rights_contents) 174 acl_rights_contents=app.cfg.acl_rights_contents)
178 if app.cfg.create_index: 175 if app.cfg.create_index:
179 app.storage.create() 176 app.storage.create()
180 app.storage.open() 177 app.storage.open()
181 178
179
182 def deinit_backends(app): 180 def deinit_backends(app):
183 app.storage.close() 181 app.storage.close()
184 app.router.close() 182 app.router.close()
185 if app.cfg.destroy_index: 183 if app.cfg.destroy_index:
186 app.storage.destroy() 184 app.storage.destroy()