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 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