# HG changeset patch # User Ludovic Chabant # Date 1359700812 28800 # Node ID 8167b9b6925ac864939c9856e51b14d05eaf2c18 # Parent 2733871775cdecbf6575107fdddfb0a73b735f64 Don't open/close connections all the time in command-line. diff -r 2733871775cd -r 8167b9b6925a manage.py --- 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