modules know how to ask for a version number from the database
This commit is contained in:
parent
56d2847285
commit
6a67795b18
19
Module.py
19
Module.py
|
@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ConfigParser import NoSectionError, NoOptionError
|
from ConfigParser import NoSectionError, NoOptionError
|
||||||
|
|
||||||
import inspect
|
import inspect
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
@ -290,12 +291,30 @@ class Module(object):
|
||||||
in their __init__ IF that structure does not already exist. Well-behaved
|
in their __init__ IF that structure does not already exist. Well-behaved
|
||||||
modules should use a prefix in their table names (eg "karma_log" rather
|
modules should use a prefix in their table names (eg "karma_log" rather
|
||||||
than "log")
|
than "log")
|
||||||
|
|
||||||
|
See also db_module_registered, below.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
dbfile = self.config.get('dr.botzo', 'database')
|
dbfile = self.config.get('dr.botzo', 'database')
|
||||||
conn = sqlite3.connect(dbfile)
|
conn = sqlite3.connect(dbfile)
|
||||||
return conn
|
return conn
|
||||||
|
|
||||||
|
def db_module_registered(self, modulename):
|
||||||
|
"""
|
||||||
|
ask the database for a version number for a module. Return that version
|
||||||
|
number if the module has registered, or None if not
|
||||||
|
"""
|
||||||
|
conn = self.get_db()
|
||||||
|
version = None
|
||||||
|
try:
|
||||||
|
cur = conn.cursor()
|
||||||
|
cur.execute("SELECT version FROM drbotzo_modules WHERE module = ?", modulename)
|
||||||
|
version = cur.fetchone()
|
||||||
|
if (version != None):
|
||||||
|
version = version[0]
|
||||||
|
finally: conn.close()
|
||||||
|
return version
|
||||||
|
|
||||||
def do(self, connection, event, nick, userhost, replypath, what, admin_unlocked):
|
def do(self, connection, event, nick, userhost, replypath, what, admin_unlocked):
|
||||||
"""
|
"""
|
||||||
Do the primary thing this module was intended to do.
|
Do the primary thing this module was intended to do.
|
||||||
|
|
Loading…
Reference in New Issue