Mercurial > wikked
changeset 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 | 2733871775cd |
children | c4e999f55ba9 |
files | manage.py |
diffstat | 1 files changed, 8 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/manage.py Thu Jan 31 12:28:10 2013 -0800 +++ b/manage.py Thu Jan 31 22:40:12 2013 -0800 @@ -5,7 +5,8 @@ # Create the app and the wiki. from wikked.web import app, wiki -from wikked.page import Page, DatabasePage +from wikked.page import Page +from wikked.db import conn_scope # Create the manager. from flask.ext.script import Manager, prompt, prompt_pass @@ -37,8 +38,9 @@ def reset(): """ Re-generates the database and the full-text-search index. """ - wiki.db.reset(wiki.getPages(from_db=False, factory=Page.factory)) - wiki.index.reset(wiki.getPages()) + with conn_scope(wiki.db): + wiki.db.reset(wiki.getPages(from_db=False, factory=Page.factory)) + wiki.index.reset(wiki.getPages()) @manager.command @@ -46,8 +48,9 @@ """ Updates the database and the full-text-search index with any changed/new files. """ - wiki.db.update(wiki.getPages(from_db=False, factory=Page.factory)) - wiki.index.update(wiki.getPages()) + with conn_scope(wiki.db): + wiki.db.update(wiki.getPages(from_db=False, factory=Page.factory)) + wiki.index.update(wiki.getPages()) @manager.command