[SQL-CVS] r3994 - in SQLObject/trunk: docs sqlobject
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: <sub...@co...> - 2009-09-25 14:50:15
|
Author: phd Date: 2009-09-25 08:50:07 -0600 (Fri, 25 Sep 2009) New Revision: 3994 Modified: SQLObject/trunk/docs/News.txt SQLObject/trunk/sqlobject/dbconnection.py Log: Merged a bugfix in logging to console fro branch 0.11, rev. 3993. Modified: SQLObject/trunk/docs/News.txt =================================================================== --- SQLObject/trunk/docs/News.txt 2009-09-25 14:47:40 UTC (rev 3993) +++ SQLObject/trunk/docs/News.txt 2009-09-25 14:50:07 UTC (rev 3994) @@ -48,6 +48,11 @@ * Removed all deprecated attribute and functions. +SQLObject 0.11.2 +================ + +* A change ported from `SQLObject 0.10.8`_. + SQLObject 0.11.1 ================ @@ -103,6 +108,11 @@ * Changed the order of testing of SQLite modules - look for external PySQLite2 before sqlite3. +SQLObject 0.10.8 +================ + +* Fixed a bug in logging to console - convert unicode to str. + SQLObject 0.10.7 ================ Modified: SQLObject/trunk/sqlobject/dbconnection.py =================================================================== --- SQLObject/trunk/sqlobject/dbconnection.py 2009-09-25 14:47:40 UTC (rev 3993) +++ SQLObject/trunk/sqlobject/dbconnection.py 2009-09-25 14:50:07 UTC (rev 3994) @@ -28,27 +28,33 @@ conn.close() class ConsoleWriter: - def __init__(self, loglevel): + def __init__(self, connection, loglevel): # loglevel: None or empty string for stdout; or 'stderr' self.loglevel = loglevel or "stdout" + self.dbEncoding = getattr(connection, "dbEncoding", "ascii") def write(self, text): logfile = getattr(sys, self.loglevel) + if isinstance(text, unicode): + try: + text = text.encode(self.dbEncoding) + except UnicodeEncodeError: + text = repr(text)[2:-1] logfile.write(text + '\n') class LogWriter: - def __init__(self, logger, loglevel): + def __init__(self, connection, logger, loglevel): self.logger = logger self.loglevel = loglevel self.logmethod = getattr(logger, loglevel) def write(self, text): self.logmethod(text) -def makeDebugWriter(loggerName, loglevel): +def makeDebugWriter(connection, loggerName, loglevel): if not loggerName: - return ConsoleWriter(loglevel) + return ConsoleWriter(connection, loglevel) import logging logger = logging.getLogger(loggerName) - return LogWriter(logger, loglevel) + return LogWriter(connection, logger, loglevel) class Boolean(object): """A bool class that also understands some special string keywords (yes/no, true/false, on/off, 1/0)""" @@ -70,7 +76,7 @@ self.debug = Boolean(debug) self.debugOutput = Boolean(debugOutput) self.debugThreading = Boolean(debugThreading) - self.debugWriter = makeDebugWriter(logger, loglevel) + self.debugWriter = makeDebugWriter(self, logger, loglevel) self.doCache = Boolean(cache) self.cache = CacheSet(cache=self.doCache) self.style = style |