diff --git a/VERSION b/VERSION index c563ea36..5c1822c2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 1.99.4 (2012-02-13 10:12:14) stable +Version 1.99.4 (2012-02-14 08:39:29) stable diff --git a/gluon/contrib/DowCommerce.py b/gluon/contrib/DowCommerce.py index ebc40f1f..8c6ea3c0 100644 --- a/gluon/contrib/DowCommerce.py +++ b/gluon/contrib/DowCommerce.py @@ -48,14 +48,13 @@ class DowCommerce: def process(self): encoded_args = urllib.urlencode(self.parameters) - if self.proxy == None: results = str(urllib.urlopen(self.url, encoded_args).read()).split(self.delimiter) else: opener = urllib.FancyURLopener(self.proxy) opened = opener.open(self.url, encoded_args) try: - results += str(opened.read()).split(self.delimiter) + results = str(opened.read()).split(self.delimiter) finally: opened.close() diff --git a/gluon/contrib/feedparser.py b/gluon/contrib/feedparser.py index a002dce0..d0fc640b 100755 --- a/gluon/contrib/feedparser.py +++ b/gluon/contrib/feedparser.py @@ -2718,7 +2718,7 @@ class _HTMLSanitizer(_BaseHTMLProcessor): # declare xlink namespace, if needed if self.mathmlOK or self.svgOK: - if filter(lambda (n,v): n.startswith('xlink:'),attrs): + if filter((lambda n,v: n.startswith('xlink:')),attrs): if not ('xmlns:xlink','http://www.w3.org/1999/xlink') in attrs: attrs.append(('xmlns:xlink','http://www.w3.org/1999/xlink')) diff --git a/gluon/contrib/generics.py b/gluon/contrib/generics.py index 0798a6e3..2f5e95cc 100644 --- a/gluon/contrib/generics.py +++ b/gluon/contrib/generics.py @@ -4,8 +4,8 @@ import re import os import cPickle import gluon.serializers -from gluon import current -from gluon.html import markmin_serializer, TAG, HTML, BODY, UL, XML +from gluon import current, HTTP +from gluon.html import markmin_serializer, TAG, HTML, BODY, UL, XML, H1 from gluon.contenttype import contenttype from gluon.contrib.pyfpdf import FPDF, HTMLMixin from gluon.sanitizer import sanitize @@ -16,13 +16,13 @@ def wrapper(f): def g(data): try: output = f(data) - except (TypeError, ValueError): - raise HTTP(405, '%s serialization error' % extension.upper()) - except ImportError: - raise HTTP(405, '%s not available' % extension.upper()) - except: - raise HTTP(405, '%s error' % extension.upper()) - return XML(ouput) + return XML(ouput) + except (TypeError, ValueError), e: + raise HTTP(405, '%s serialization error' % e) + except ImportError, e: + raise HTTP(405, '%s not available' % e) + except Exception, e: + raise HTTP(405, '%s error' % e) return g def latex_from_html(html): @@ -32,13 +32,13 @@ def latex_from_html(html): def pdflatex_from_html(html): if os.system('which pdflatex > /dev/null')==0: markmin=TAG(html).element('body').flatten(markmin_serializer) - out,warning,errors=markmin2pdf(markmin) + out,warnings,errors=markmin2pdf(markmin) if errors: current.response.headers['Content-Type']='text/html' raise HTTP(405,HTML(BODY(H1('errors'), - LU(*errors), + UL(*errors), H1('warnings'), - LU(*warnings))).xml()) + UL(*warnings))).xml()) else: return XML(out) diff --git a/gluon/contrib/memdb.py b/gluon/contrib/memdb.py index 5fd45ceb..5c1b5dd5 100644 --- a/gluon/contrib/memdb.py +++ b/gluon/contrib/memdb.py @@ -21,6 +21,7 @@ import csv import copy import gluon.validators as validators from gluon.storage import Storage +from gluon import SQLTABLE import random SQL_DIALECTS = {'memcache': { @@ -766,10 +767,10 @@ class Rows(object): def xml(self): """ - serializes the table using sqlhtml.SQLTABLE (if present) + serializes the table using SQLTABLE (if present) """ - return sqlhtml.SQLTABLE(self).xml() + return SQLTABLE(self).xml() def test_all(): diff --git a/gluon/dal.py b/gluon/dal.py index 6ab6672f..39f6084c 100644 --- a/gluon/dal.py +++ b/gluon/dal.py @@ -1468,7 +1468,7 @@ class BaseAdapter(ConnectionPool): def parse_value(self, value, field_type): if field_type != 'blob' and isinstance(value, str): try: - value = value.decode(db._db_codec) + value = value.decode(self.db._db_codec) except Exception: pass if isinstance(value, unicode): @@ -3891,7 +3891,7 @@ class MongoDBAdapter(NoSQLAdapter): if inst == "cannot specify database without a username and password": raise SyntaxError("You are probebly running version 1.1 of pymongo which contains a bug which requires authentication. Update your pymongo.") else: - raise SyntaxError(Mer("This is not an official Mongodb uri (http://www.mongodb.org/display/DOCS/Connections) Error : %s" % inst)) + raise SyntaxError("This is not an official Mongodb uri (http://www.mongodb.org/display/DOCS/Connections) Error : %s" % inst) self.pool_connection(connect,cursor=False) @@ -4182,7 +4182,7 @@ class MongoDBAdapter(NoSQLAdapter): return {self.expand(first) : {"$in" : [ second[:-1]]} } elif second==[] or second==(): return {1:0} - items.append(self.expand(item, first.type) for item in second) + items = [self.expand(item, first.type) for item in second] return {self.expand(first) : {"$in" : items} } def LIKE(self, first, second): @@ -4252,32 +4252,32 @@ class MongoDBAdapter(NoSQLAdapter): return result def ADD(self, first, second): - raise NotSupported, "This must yet be replaced with javescript in order to accomplish this. Sorry" + raise NotImplementedError, "This must yet be replaced with javescript in order to accomplish this. Sorry" return '%s + %s' % (self.expand(first), self.expand(second, first.type)) def SUB(self, first, second): - raise NotSupported, "This must yet be replaced with javescript in order to accomplish this. Sorry" + raise NotImplementedError, "This must yet be replaced with javescript in order to accomplish this. Sorry" return '(%s - %s)' % (self.expand(first), self.expand(second, first.type)) def MUL(self, first, second): - raise NotSupported, "This must yet be replaced with javescript in order to accomplish this. Sorry" + raise NotImplementedError, "This must yet be replaced with javescript in order to accomplish this. Sorry" return '(%s * %s)' % (self.expand(first), self.expand(second, first.type)) def DIV(self, first, second): - raise NotSupported, "This must yet be replaced with javescript in order to accomplish this. Sorry" + raise NotImplementedError, "This must yet be replaced with javescript in order to accomplish this. Sorry" return '(%s / %s)' % (self.expand(first), self.expand(second, first.type)) def MOD(self, first, second): - raise NotSupported, "This must yet be replaced with javescript in order to accomplish this. Sorry" + raise NotImplementedError, "This must yet be replaced with javescript in order to accomplish this. Sorry" return '(%s %% %s)' % (self.expand(first), self.expand(second, first.type)) def AS(self, first, second): - raise NotSupported, "This must yet be replaced with javescript in order to accomplish this. Sorry" + raise NotImplementedError, "This must yet be replaced with javescript in order to accomplish this. Sorry" return '%s AS %s' % (self.expand(first), second) #We could implement an option that simulates a full featured SQL database. But I think the option should be set explicit or implemented as another library. def ON(self, first, second): - raise NotSupported, "This is not possible in NoSQL, but can be simulated with a wrapper." + raise NotImplementedError, "This is not possible in NoSQL, but can be simulated with a wrapper." return '%s ON %s' % (self.expand(first), self.expand(second)) def COMMA(self, first, second): @@ -4311,7 +4311,7 @@ class MongoDBAdapter(NoSQLAdapter): return {self.expand(first) : {"$in" : [ second[:-1]]} } elif second==[] or second==(): return {1:0} - items.append(self.expand(item, first.type) for item in second) + items = [self.expand(item, first.type) for item in second] return {self.expand(first) : {"$in" : items} } #TODO verify full compatibilty with official SQL Like operator @@ -4390,36 +4390,36 @@ class MongoDBAdapter(NoSQLAdapter): #TODO javascript has math def ADD(self, first, second): - raise NotSupported, "This must yet be replaced with javescript in order to accomplish this. Sorry" + raise NotImplementedError, "This must yet be replaced with javescript in order to accomplish this. Sorry" return '%s + %s' % (self.expand(first), self.expand(second, first.type)) #TODO javascript has math def SUB(self, first, second): - raise NotSupported, "This must yet be replaced with javescript in order to accomplish this. Sorry" + raise NotImplementedError, "This must yet be replaced with javescript in order to accomplish this. Sorry" return '(%s - %s)' % (self.expand(first), self.expand(second, first.type)) #TODO javascript has math def MUL(self, first, second): - raise NotSupported, "This must yet be replaced with javescript in order to accomplish this. Sorry" + raise NotImplementedError, "This must yet be replaced with javescript in order to accomplish this. Sorry" return '(%s * %s)' % (self.expand(first), self.expand(second, first.type)) #TODO javascript has math def DIV(self, first, second): - raise NotSupported, "This must yet be replaced with javescript in order to accomplish this. Sorry" + raise NotImplementedError, "This must yet be replaced with javescript in order to accomplish this. Sorry" return '(%s / %s)' % (self.expand(first), self.expand(second, first.type)) #TODO javascript has math def MOD(self, first, second): - raise NotSupported, "This must yet be replaced with javescript in order to accomplish this. Sorry" + raise NotImplementedError, "This must yet be replaced with javescript in order to accomplish this. Sorry" return '(%s %% %s)' % (self.expand(first), self.expand(second, first.type)) #TODO javascript can do this def AS(self, first, second): - raise NotSupported, "This must yet be replaced with javescript in order to accomplish this. Sorry" + raise NotImplementedError, "This must yet be replaced with javescript in order to accomplish this. Sorry" return '%s AS %s' % (self.expand(first), second) #We could implement an option that simulates a full featured SQL database. But I think the option should be set explicit or implemented as another library. def ON(self, first, second): - raise NotSupported, "This is not possible in NoSQL, but can be simulated with a wrapper." + raise NotImplementedError, "This is not possible in NoSQL, but can be simulated with a wrapper." return '%s ON %s' % (self.expand(first), self.expand(second)) #TODO is this used in mongodb? diff --git a/gluon/scheduler.py b/gluon/scheduler.py index 99797f9c..f103efb9 100644 --- a/gluon/scheduler.py +++ b/gluon/scheduler.py @@ -160,7 +160,9 @@ def executor(queue,task): result = dumps(_function(*args,**vars)) else: ### for testing purpose only - result = eval(task.function)(*loads(task.args, list_hook),**loads(task.vars, object_hook=_decode_dict)) + result = eval(task.function)( + *loads(task.args, object_hook=_decode_dict), + **loads(task.vars, object_hook=_decode_dict)) stdout, sys.stdout = sys.stdout, stdout queue.put(TaskReport(COMPLETED, result,stdout.getvalue())) except BaseException,e: diff --git a/gluon/sqlhtml.py b/gluon/sqlhtml.py index 31426028..f4c353ae 100644 --- a/gluon/sqlhtml.py +++ b/gluon/sqlhtml.py @@ -1606,7 +1606,7 @@ class SQLFORM(FORM): table = db[request.args[-2]] if ondelete: ondelete(table,request.args[-1]) - ret = db(table[self.id_field_name]==request.args[-1]).delete() + ret = db(table[table._id.name]==request.args[-1]).delete() return ret elif csv and len(request.args)>0 and request.args[-1]=='csv': if request.vars.keywords: