fixed many small errors, thanks Marin Pranjić

This commit is contained in:
Massimo Di Pierro
2012-02-14 08:40:06 -06:00
parent 1c808ecda2
commit 01b09a450e
8 changed files with 40 additions and 38 deletions
+1 -1
View File
@@ -1 +1 @@
Version 1.99.4 (2012-02-13 10:12:14) stable Version 1.99.4 (2012-02-14 08:39:29) stable
+1 -2
View File
@@ -48,14 +48,13 @@ class DowCommerce:
def process(self): def process(self):
encoded_args = urllib.urlencode(self.parameters) encoded_args = urllib.urlencode(self.parameters)
if self.proxy == None: if self.proxy == None:
results = str(urllib.urlopen(self.url, encoded_args).read()).split(self.delimiter) results = str(urllib.urlopen(self.url, encoded_args).read()).split(self.delimiter)
else: else:
opener = urllib.FancyURLopener(self.proxy) opener = urllib.FancyURLopener(self.proxy)
opened = opener.open(self.url, encoded_args) opened = opener.open(self.url, encoded_args)
try: try:
results += str(opened.read()).split(self.delimiter) results = str(opened.read()).split(self.delimiter)
finally: finally:
opened.close() opened.close()
+1 -1
View File
@@ -2718,7 +2718,7 @@ class _HTMLSanitizer(_BaseHTMLProcessor):
# declare xlink namespace, if needed # declare xlink namespace, if needed
if self.mathmlOK or self.svgOK: 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: if not ('xmlns:xlink','http://www.w3.org/1999/xlink') in attrs:
attrs.append(('xmlns:xlink','http://www.w3.org/1999/xlink')) attrs.append(('xmlns:xlink','http://www.w3.org/1999/xlink'))
+12 -12
View File
@@ -4,8 +4,8 @@ import re
import os import os
import cPickle import cPickle
import gluon.serializers import gluon.serializers
from gluon import current from gluon import current, HTTP
from gluon.html import markmin_serializer, TAG, HTML, BODY, UL, XML from gluon.html import markmin_serializer, TAG, HTML, BODY, UL, XML, H1
from gluon.contenttype import contenttype from gluon.contenttype import contenttype
from gluon.contrib.pyfpdf import FPDF, HTMLMixin from gluon.contrib.pyfpdf import FPDF, HTMLMixin
from gluon.sanitizer import sanitize from gluon.sanitizer import sanitize
@@ -16,13 +16,13 @@ def wrapper(f):
def g(data): def g(data):
try: try:
output = f(data) output = f(data)
except (TypeError, ValueError): return XML(ouput)
raise HTTP(405, '%s serialization error' % extension.upper()) except (TypeError, ValueError), e:
except ImportError: raise HTTP(405, '%s serialization error' % e)
raise HTTP(405, '%s not available' % extension.upper()) except ImportError, e:
except: raise HTTP(405, '%s not available' % e)
raise HTTP(405, '%s error' % extension.upper()) except Exception, e:
return XML(ouput) raise HTTP(405, '%s error' % e)
return g return g
def latex_from_html(html): def latex_from_html(html):
@@ -32,13 +32,13 @@ def latex_from_html(html):
def pdflatex_from_html(html): def pdflatex_from_html(html):
if os.system('which pdflatex > /dev/null')==0: if os.system('which pdflatex > /dev/null')==0:
markmin=TAG(html).element('body').flatten(markmin_serializer) markmin=TAG(html).element('body').flatten(markmin_serializer)
out,warning,errors=markmin2pdf(markmin) out,warnings,errors=markmin2pdf(markmin)
if errors: if errors:
current.response.headers['Content-Type']='text/html' current.response.headers['Content-Type']='text/html'
raise HTTP(405,HTML(BODY(H1('errors'), raise HTTP(405,HTML(BODY(H1('errors'),
LU(*errors), UL(*errors),
H1('warnings'), H1('warnings'),
LU(*warnings))).xml()) UL(*warnings))).xml())
else: else:
return XML(out) return XML(out)
+3 -2
View File
@@ -21,6 +21,7 @@ import csv
import copy import copy
import gluon.validators as validators import gluon.validators as validators
from gluon.storage import Storage from gluon.storage import Storage
from gluon import SQLTABLE
import random import random
SQL_DIALECTS = {'memcache': { SQL_DIALECTS = {'memcache': {
@@ -766,10 +767,10 @@ class Rows(object):
def xml(self): 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(): def test_all():
+18 -18
View File
@@ -1468,7 +1468,7 @@ class BaseAdapter(ConnectionPool):
def parse_value(self, value, field_type): def parse_value(self, value, field_type):
if field_type != 'blob' and isinstance(value, str): if field_type != 'blob' and isinstance(value, str):
try: try:
value = value.decode(db._db_codec) value = value.decode(self.db._db_codec)
except Exception: except Exception:
pass pass
if isinstance(value, unicode): if isinstance(value, unicode):
@@ -3891,7 +3891,7 @@ class MongoDBAdapter(NoSQLAdapter):
if inst == "cannot specify database without a username and password": 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.") raise SyntaxError("You are probebly running version 1.1 of pymongo which contains a bug which requires authentication. Update your pymongo.")
else: 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) self.pool_connection(connect,cursor=False)
@@ -4182,7 +4182,7 @@ class MongoDBAdapter(NoSQLAdapter):
return {self.expand(first) : {"$in" : [ second[:-1]]} } return {self.expand(first) : {"$in" : [ second[:-1]]} }
elif second==[] or second==(): elif second==[] or second==():
return {1:0} 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} } return {self.expand(first) : {"$in" : items} }
def LIKE(self, first, second): def LIKE(self, first, second):
@@ -4252,32 +4252,32 @@ class MongoDBAdapter(NoSQLAdapter):
return result return result
def ADD(self, first, second): 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)) return '%s + %s' % (self.expand(first), self.expand(second, first.type))
def SUB(self, first, second): 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)) return '(%s - %s)' % (self.expand(first), self.expand(second, first.type))
def MUL(self, first, second): 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)) return '(%s * %s)' % (self.expand(first), self.expand(second, first.type))
def DIV(self, first, second): 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)) return '(%s / %s)' % (self.expand(first), self.expand(second, first.type))
def MOD(self, first, second): 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)) return '(%s %% %s)' % (self.expand(first), self.expand(second, first.type))
def AS(self, first, second): 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) 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. #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): 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)) return '%s ON %s' % (self.expand(first), self.expand(second))
def COMMA(self, first, second): def COMMA(self, first, second):
@@ -4311,7 +4311,7 @@ class MongoDBAdapter(NoSQLAdapter):
return {self.expand(first) : {"$in" : [ second[:-1]]} } return {self.expand(first) : {"$in" : [ second[:-1]]} }
elif second==[] or second==(): elif second==[] or second==():
return {1:0} 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} } return {self.expand(first) : {"$in" : items} }
#TODO verify full compatibilty with official SQL Like operator #TODO verify full compatibilty with official SQL Like operator
@@ -4390,36 +4390,36 @@ class MongoDBAdapter(NoSQLAdapter):
#TODO javascript has math #TODO javascript has math
def ADD(self, first, second): 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)) return '%s + %s' % (self.expand(first), self.expand(second, first.type))
#TODO javascript has math #TODO javascript has math
def SUB(self, first, second): 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)) return '(%s - %s)' % (self.expand(first), self.expand(second, first.type))
#TODO javascript has math #TODO javascript has math
def MUL(self, first, second): 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)) return '(%s * %s)' % (self.expand(first), self.expand(second, first.type))
#TODO javascript has math #TODO javascript has math
def DIV(self, first, second): 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)) return '(%s / %s)' % (self.expand(first), self.expand(second, first.type))
#TODO javascript has math #TODO javascript has math
def MOD(self, first, second): 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)) return '(%s %% %s)' % (self.expand(first), self.expand(second, first.type))
#TODO javascript can do this #TODO javascript can do this
def AS(self, first, second): 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) 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. #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): 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)) return '%s ON %s' % (self.expand(first), self.expand(second))
#TODO is this used in mongodb? #TODO is this used in mongodb?
+3 -1
View File
@@ -160,7 +160,9 @@ def executor(queue,task):
result = dumps(_function(*args,**vars)) result = dumps(_function(*args,**vars))
else: else:
### for testing purpose only ### 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 stdout, sys.stdout = sys.stdout, stdout
queue.put(TaskReport(COMPLETED, result,stdout.getvalue())) queue.put(TaskReport(COMPLETED, result,stdout.getvalue()))
except BaseException,e: except BaseException,e:
+1 -1
View File
@@ -1606,7 +1606,7 @@ class SQLFORM(FORM):
table = db[request.args[-2]] table = db[request.args[-2]]
if ondelete: if ondelete:
ondelete(table,request.args[-1]) 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 return ret
elif csv and len(request.args)>0 and request.args[-1]=='csv': elif csv and len(request.args)>0 and request.args[-1]=='csv':
if request.vars.keywords: if request.vars.keywords: