comparison manage.py @ 52:8167b9b6925a

Don't open/close connections all the time in command-line.
author Ludovic Chabant <ludovic@chabant.com>
date Thu, 31 Jan 2013 22:40:12 -0800
parents 86ee1b696070
children 494f3c4660ed
comparison
equal deleted inserted replaced
51:2733871775cd 52:8167b9b6925a
3 from wikked import settings 3 from wikked import settings
4 settings.LOG_FORMAT = "[%(levelname)s]: %(message)s" 4 settings.LOG_FORMAT = "[%(levelname)s]: %(message)s"
5 5
6 # Create the app and the wiki. 6 # Create the app and the wiki.
7 from wikked.web import app, wiki 7 from wikked.web import app, wiki
8 from wikked.page import Page, DatabasePage 8 from wikked.page import Page
9 from wikked.db import conn_scope
9 10
10 # Create the manager. 11 # Create the manager.
11 from flask.ext.script import Manager, prompt, prompt_pass 12 from flask.ext.script import Manager, prompt, prompt_pass
12 manager = Manager(app) 13 manager = Manager(app)
13 14
35 36
36 @manager.command 37 @manager.command
37 def reset(): 38 def reset():
38 """ Re-generates the database and the full-text-search index. 39 """ Re-generates the database and the full-text-search index.
39 """ 40 """
40 wiki.db.reset(wiki.getPages(from_db=False, factory=Page.factory)) 41 with conn_scope(wiki.db):
41 wiki.index.reset(wiki.getPages()) 42 wiki.db.reset(wiki.getPages(from_db=False, factory=Page.factory))
43 wiki.index.reset(wiki.getPages())
42 44
43 45
44 @manager.command 46 @manager.command
45 def update(): 47 def update():
46 """ Updates the database and the full-text-search index with any 48 """ Updates the database and the full-text-search index with any
47 changed/new files. 49 changed/new files.
48 """ 50 """
49 wiki.db.update(wiki.getPages(from_db=False, factory=Page.factory)) 51 with conn_scope(wiki.db):
50 wiki.index.update(wiki.getPages()) 52 wiki.db.update(wiki.getPages(from_db=False, factory=Page.factory))
53 wiki.index.update(wiki.getPages())
51 54
52 55
53 @manager.command 56 @manager.command
54 def list(): 57 def list():
55 """ Lists page names in the wiki. 58 """ Lists page names in the wiki.