def __init__(self, URI): # i f*****g hate encodings. This string is encoded here, next by SQLObject, then the DB adapter takes it's shot again # i tried to make this work somehow, but mysql is giving me a hard time import sqlobject from SQLObject_model import Log, Channel from SQLObjectLog import SQLObjectLog # set up a connection connection = sqlobject.connectionForURI( URI, sqlobject_encoding='utf-8') sqlobject.sqlhub.processConnection = connection #make sure we have all used tables Channel.createTable(ifNotExists=True) Log.createTable(ifNotExists=True) #create a factory function def createLog( irc, channel ): return SQLObjectLog( irc, channel) self.createLog = createLog
def __init__(self, irc, channel): # get the correct Channel Object network = str(irc.network) channel = channel.lstrip('#') c = Channel.selectBy(network=network, name=channel) if c.count() == 0: c = Channel(network = network, name=channel) else: c = c[0] def doLog(m, nick, *args): #assume stuff is latin-1, im sick and tired of this encoding faggotry. # mysqlobject is a f****t too, reencoding this again # i hope sqlobject 0.9.1 fixed this, i had to hack mysqlconnection.py #112 >_< text = ' '.join(args).decode('cp1252') Log( channel=c, created_on=datetime.datetime.now(), type=m, nick=nick, text=text) self.doLog = doLog