-#!/usr/bin/python
-#
# Copyright (C) 2013 Simo Sorce <simo@redhat.com>
#
# see file 'COPYING' for use and warranty information
timestamp = stat.st_mtime
if self._config is None or timestamp > self._timestamp:
self._config = ConfigParser.RawConfigParser()
+ self._config.optionxform = str
self._config.read(self._filename)
return self._config
class Store(Log):
- def __init__(self, config_name):
- if config_name not in cherrypy.config:
- raise NameError('Unknown database %s' % config_name)
- name = cherrypy.config[config_name]
+ def __init__(self, config_name=None, database_url=None):
+ if config_name is None and database_url is None:
+ raise ValueError('config_name or database_url must be provided')
+ if config_name:
+ if config_name not in cherrypy.config:
+ raise NameError('Unknown database %s' % config_name)
+ name = cherrypy.config[config_name]
+ else:
+ name = database_url
if name.startswith('configfile://'):
_, filename = name.split('://')
self._db = FileStore(filename)
self.error("Failed to delete data from %s: [%s]" % (table, e))
def _reset_data(self, table):
+ q = None
try:
q = self._query(self._db, table, UNIQUE_DATA_COLUMNS)
q.drop()