From a445d1f6cdfceac3c6bd519ae29ada517e716e04 Mon Sep 17 00:00:00 2001 From: lars Date: Sun, 9 May 2010 15:44:23 +0000 Subject: [PATCH] moved database URI to a separate config file (BASE_DIR/wortschlucker.conf) --- wortschlucker/src/wortschlucker.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/wortschlucker/src/wortschlucker.py b/wortschlucker/src/wortschlucker.py index 97d25b3..accac48 100755 --- a/wortschlucker/src/wortschlucker.py +++ b/wortschlucker/src/wortschlucker.py @@ -11,22 +11,28 @@ sys.path.insert(0, os.path.join(BASE_DIR, "src")) import bobo import forms import sqlobject -import cherrypy -from genshi.template import TemplateLoader import genshi.filters import genshi.input +import genshi.template import genshi import formencode -import datetime import webob +import ConfigParser +import datetime import mimetypes import uuid import re -db_filename = os.path.join(BASE_DIR, "database.sqlite") -database = sqlobject.connectionForURI("sqlite://" + db_filename) -sqlobject.sqlhub.processConnection = database -loader = TemplateLoader(os.path.join(BASE_DIR, 'templates'), auto_reload=True) +CONFIG_FILE = os.path.join(BASE_DIR, "wortschlucker.conf") + + +""" *** Initialization *** """ +config = ConfigParser.SafeConfigParser() +config.read(CONFIG_FILE) +db_uri = config.get("database", "uri") +sqlobject.sqlhub.processConnection = sqlobject.connectionForURI(db_uri) +loader = genshi.template.TemplateLoader(os.path.join(BASE_DIR, 'templates'), auto_reload=False) + BASE_DICT = { "base_url": "/", # the trailing slash is necessary @@ -635,11 +641,9 @@ def static_files(p1=None, p2=None, p3=None): for table in (Poll, ContentSubmission, PollSetting, PollRelation): - #Poll.dropTable() + #table.dropTable() if not table.tableExists(): table.createTable() -for poll in Poll.select(): - print poll # this line allows to use wortschlucker with mod_wsgi # see: http://groups.google.com/group/bobo-web/msg/2ba55fc381658cd1