Module: move REGEXP definition to every get_db() call

also remove some self.conn stuff that no one used anymore
This commit is contained in:
Brian S. Stephan 2011-06-21 17:22:24 -05:00
parent 7220025f0a
commit ad4d75f724
1 changed files with 7 additions and 11 deletions

View File

@ -43,17 +43,6 @@ class Module(object):
self.is_shutdown = False
# open database connection
dbfile = self.config.get('dr.botzo', 'database')
self.conn = sqlite3.connect(dbfile)
self.conn.row_factory = sqlite3.Row
# setup regexp function in sqlite
def regexp(expr, item):
reg = re.compile(expr, re.IGNORECASE)
return reg.search(item) is not None
self.conn.create_function('REGEXP', 2, regexp)
# set up database for this module
self.db_init()
@ -187,6 +176,13 @@ class Module(object):
dbfile = self.config.get('dr.botzo', 'database')
conn = sqlite3.connect(dbfile)
conn.row_factory = sqlite3.Row
# setup regexp function in sqlite
def regexp(expr, item):
reg = re.compile(expr, re.IGNORECASE)
return reg.search(item) is not None
conn.create_function('REGEXP', 2, regexp)
return conn
def db_module_registered(self, modulename):