def sqlmap(self): try: stream = DataInput(request.environ['wsgi.input'].read( int(request.environ['CONTENT_LENGTH']))) ret = "" while stream.dataAvailable() > 0: (type, key, values) = Codec.decodeRequest(stream) log.debug("sqlmap request %s" % (key)) if type == Codec.SELECT: ret = Codec.encodeResults(self.session.sqlmap(key, values)) elif type == Codec.UPDATE: ret = Codec.encodeLastId( self.session.sqlmap(key, values).lastrowid) elif type == Codec.FUNCTION: if hasattr(self, key): ret = getattr(self, key)(*values) else: raise Exception("Unknown FUNCTION call %s" % (key)) else: raise Exception("Unknown call type %s" % (type)) self.session.commit() return ret except Exception, e: self.session.rollback() msg = Exception.__str__(e) filename, lineno, name, line = traceback.extract_tb( sys.exc_info()[2])[-1] return Codec.encodeError(filename, lineno, msg)
def sqlmap(self): try: stream = DataInput(request.environ['wsgi.input'].read(int(request.environ['CONTENT_LENGTH']))) ret = "" while stream.dataAvailable() > 0: (type, key, values) = Codec.decodeRequest(stream) log.debug("sqlmap request %s" % (key)) if type == Codec.SELECT: ret = Codec.encodeResults(self.session.sqlmap(key, values)) elif type == Codec.UPDATE: ret = Codec.encodeLastId(self.session.sqlmap(key, values).lastrowid) elif type == Codec.FUNCTION: if hasattr(self, key): ret = getattr(self, key)(*values) else: raise Exception("Unknown FUNCTION call %s" % (key)) else: raise Exception("Unknown call type %s" % (type)) self.session.commit() return ret except Exception, e: self.session.rollback() msg = Exception.__str__(e) filename, lineno, name, line = traceback.extract_tb(sys.exc_info()[2])[-1] return Codec.encodeError(filename, lineno, msg)
def UpdateClass(self, eventid, course, classcode, carid): UpdateClassResults(self.session, eventid, course, classcode, carid) return Codec.encodeLastId(-1)
def GetCarAttributes(self, attr): rs = self.session.connection().execute( "select distinct %s from cars where LOWER(%s)!=%s and UPPER(%s)!=%s order by %s collate nocase" \ % tuple([attr]*6)) return Codec.encodeResults(rs)