moved database URI to a separate config file (BASE_DIR/wortschlucker.conf)

This commit is contained in:
lars 2010-05-09 15:44:23 +00:00
parent 76923a682e
commit a445d1f6cd

View file

@ -11,22 +11,28 @@ sys.path.insert(0, os.path.join(BASE_DIR, "src"))
import bobo import bobo
import forms import forms
import sqlobject import sqlobject
import cherrypy
from genshi.template import TemplateLoader
import genshi.filters import genshi.filters
import genshi.input import genshi.input
import genshi.template
import genshi import genshi
import formencode import formencode
import datetime
import webob import webob
import ConfigParser
import datetime
import mimetypes import mimetypes
import uuid import uuid
import re import re
db_filename = os.path.join(BASE_DIR, "database.sqlite") CONFIG_FILE = os.path.join(BASE_DIR, "wortschlucker.conf")
database = sqlobject.connectionForURI("sqlite://" + db_filename)
sqlobject.sqlhub.processConnection = database
loader = TemplateLoader(os.path.join(BASE_DIR, 'templates'), auto_reload=True) """ *** 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_DICT = {
"base_url": "/", # the trailing slash is necessary "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): for table in (Poll, ContentSubmission, PollSetting, PollRelation):
#Poll.dropTable() #table.dropTable()
if not table.tableExists(): if not table.tableExists():
table.createTable() table.createTable()
for poll in Poll.select():
print poll
# this line allows to use wortschlucker with mod_wsgi # this line allows to use wortschlucker with mod_wsgi
# see: http://groups.google.com/group/bobo-web/msg/2ba55fc381658cd1 # see: http://groups.google.com/group/bobo-web/msg/2ba55fc381658cd1