From b832ca68ee22c852ffc869e736c0e44595ec290f Mon Sep 17 00:00:00 2001 From: Massimo Di Pierro Date: Wed, 1 Feb 2012 11:36:26 -0600 Subject: [PATCH] fixed some issues in dal.py and sqlhtml.py thanks Michele --- VERSION | 2 +- gluon/dal.py | 2 +- gluon/sqlhtml.py | 10 +++++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/VERSION b/VERSION index 7d06cae5..9a6896d1 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 1.99.4 (2012-01-31 08:48:24) stable +Version 1.99.4 (2012-02-01 11:35:57) stable diff --git a/gluon/dal.py b/gluon/dal.py index 8896636e..09b9b4a5 100644 --- a/gluon/dal.py +++ b/gluon/dal.py @@ -1930,7 +1930,7 @@ class PostgreSQLAdapter(BaseAdapter): def __init__(self,db,uri,pool_size=0,folder=None,db_codec ='UTF-8', credential_decoder=lambda x:x, driver_args={}, adapter_args={}): - if not self.drivers.get('psycopg2') and not self.drivers.get('psycopg2'): + if not self.drivers.get('psycopg2') and not self.drivers.get('pg8000'): raise RuntimeError, "Unable to import any drivers (psycopg2 or pg8000)" self.db = db self.dbengine = "postgres" diff --git a/gluon/sqlhtml.py b/gluon/sqlhtml.py index dd09d812..7c83bc5e 100644 --- a/gluon/sqlhtml.py +++ b/gluon/sqlhtml.py @@ -1297,6 +1297,9 @@ class SQLFORM(FORM): @staticmethod def build_query(fields,keywords): + if isinstance(keywords,(tuple,list)): + keywords = keywords[0] + request.vars.keywords = keywords key = keywords.strip() if key and not ' ' in key and not '"' in key and not "'" in key: SEARCHABLE_TYPES = ('string','text','list:string') @@ -1647,12 +1650,13 @@ class SQLFORM(FORM): console.append(form) keywords = request.vars.get('keywords','') try: - subquery = SQLFORM.build_query(sfields, keywords) + if callable(searchable): + subquery = searchable(sfields, keywords) + else: + subquery = SQLFORM.build_query(sfields, keywords) except RuntimeError: subquery = None error = T('Invalid query') - elif callable(searchable): - subquery = searchable(keywords,fields) else: subquery = None if subquery: