comparison MoinMoin/app.py @ 854:c9a78e5a58c4 storage-ng

fix script startup deadlock, add script params to create storage and index, fix fs store To build an index, use this: moin index-build -s -i moin index-build --storage-create --index-create Usually moin would expect an existing index and storage when starting up and fail if it is not there. This is a problem for moin index-* commands, which are used to build an index. By giving -s, you force it to create the storage where specified by the config. By giving -i, you force it to create the index where specified by the config. fs storage used os.mkdir. use os.makedirs to support multiple levels of dirs getting create. catch exception if the dir is already there.
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 24 Sep 2011 02:54:21 +0200
parents 5ad4ae0b1e09
children e1a68b3721cc
comparison
equal deleted inserted replaced
853:bc36120169a9 854:c9a78e5a58c4
38 from MoinMoin.themes import setup_jinja_env, themed_error 38 from MoinMoin.themes import setup_jinja_env, themed_error
39 39
40 from MoinMoin.util.clock import Clock 40 from MoinMoin.util.clock import Clock
41 41
42 42
43 def create_app(config=None): 43 def create_app(config=None, create_index=False, create_storage=False):
44 """ 44 """
45 simple wrapper around create_app_ext() for flask-script 45 simple wrapper around create_app_ext() for flask-script
46 """ 46 """
47 return create_app_ext(flask_config_file=config) 47 return create_app_ext(flask_config_file=config,
48 create_index=create_index,
49 create_storage=create_storage)
48 50
49 51
50 def create_app_ext(flask_config_file=None, flask_config_dict=None, 52 def create_app_ext(flask_config_file=None, flask_config_dict=None,
51 moin_config_class=None, warn_default=True, **kwargs 53 moin_config_class=None, warn_default=True, **kwargs
52 ): 54 ):
168 app.router = routing.Backend(app.cfg.namespace_mapping) 170 app.router = routing.Backend(app.cfg.namespace_mapping)
169 if app.cfg.create_storage: 171 if app.cfg.create_storage:
170 app.router.create() 172 app.router.create()
171 app.router.open() 173 app.router.open()
172 app.storage = indexing.IndexingMiddleware(app.cfg.index_dir, app.router, wiki_name=app.cfg.interwikiname) # XXX give user name etc. 174 app.storage = indexing.IndexingMiddleware(app.cfg.index_dir, app.router, wiki_name=app.cfg.interwikiname) # XXX give user name etc.
173 if app.cfg.create_storage: 175 if app.cfg.create_index:
174 app.storage.create() 176 app.storage.create()
175 app.storage.open() 177 app.storage.open()
176 178
177 def deinit_backends(app): 179 def deinit_backends(app):
178 app.storage.close() 180 app.storage.close()
179 app.router.close() 181 app.router.close()
182 if app.cfg.destroy_index:
183 app.storage.destroy()
180 if app.cfg.destroy_storage: 184 if app.cfg.destroy_storage:
181 app.storage.destroy()
182 app.router.destroy() 185 app.router.destroy()
183 186
184 187
185 def setup_user(): 188 def setup_user():
186 """ 189 """