# HG changeset patch # User catherine@dellzilla # Date 1266445279 18000 # Node ID 67f23ccba6f5c96c66b56caad501a8c913102f06 # Parent 46589473c36bf6593cdd732357b56ab4928a1626 unused stub for postgres blob display. segfaults diff -r 46589473c36b -r 67f23ccba6f5 sqlpython/sqlpyPlus.py --- a/sqlpython/sqlpyPlus.py Wed Feb 17 15:39:33 2010 -0500 +++ b/sqlpython/sqlpyPlus.py Wed Feb 17 17:21:19 2010 -0500 @@ -31,6 +31,10 @@ from metadata import metaqueries from plothandler import Plot from sqlpython import Parser, cx_Oracle, psycopg2 +try: + import psycopg2.extensions +except ImportError: + pass import imagedetect import warnings warnings.filterwarnings('ignore', 'BaseException.message', DeprecationWarning) @@ -327,7 +331,24 @@ self.url, self.url, self.imgwidth) else: return '(BLOB not saved, check bloblimit)' - + +class BlobDisplayer_postgresql(BlobDisplayer): + imgwidth = 400 + def __init__(self, blob_oid, under_limit, sqlpython_instance): + self.url = '' + import pdb; pdb.set_trace() + if under_limit: + if self.folder_ok(): + self.lobject = psycopg2.extensions.lobject(conn=sqlpython_instance.current_instance.connection, oid=blob_oid) + self.blob = self.lobject.read() + self.extension = imagedetect.extension_from_data(self.blob) + self.file_name = '%s/%d%s' % ( + os.path.join(os.getcwd(), self.folder_name), + blob_oid, self.extension) + self.url = 'file://%s' % self.file_name + self.lobject.export(self.file_name) + self.lobject.close() + class Abbreviatable_List(list): def match(self, target): target = target.lower() @@ -773,6 +794,15 @@ or datum for (datum, coltype) in zip(row, self.coltypes)] for (rownum, row) in enumerate(self.rows)] + ''' + TODO: Segfault! Drat! + elif psycopg2 and set(psycopg2.ROWID.values).intersection(set(self.coltypes)): + self.rows = [ + [( (coltype in psycopg2.ROWID.values) + and BlobDisplayer_postgresql(datum, (rownum < self.bloblimit), self)) + or datum + for (datum, coltype) in zip(row, self.coltypes)] + for (rownum, row) in enumerate(self.rows)] ''' self.rc = len(self.rows) if self.rc != 0: resultset = ResultSet()