Skip to content

Commit

Permalink
fixed many small errors, thanks Marin Pranjić
Browse files Browse the repository at this point in the history
  • Loading branch information
mdipierro committed Feb 14, 2012
1 parent 1c808ec commit 01b09a4
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 38 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Version 1.99.4 (2012-02-13 10:12:14) stable
Version 1.99.4 (2012-02-14 08:39:29) stable
3 changes: 1 addition & 2 deletions gluon/contrib/DowCommerce.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,13 @@ def __init__(self, username=None, password=None, demomode=False):

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()

Expand Down
2 changes: 1 addition & 1 deletion gluon/contrib/feedparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2718,7 +2718,7 @@ def unknown_starttag(self, tag, attrs):

# 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'))

Expand Down
24 changes: 12 additions & 12 deletions gluon/contrib/generics.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
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
Expand All @@ -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):
Expand All @@ -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)

Expand Down
5 changes: 3 additions & 2 deletions gluon/contrib/memdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import copy
import gluon.validators as validators
from gluon.storage import Storage
from gluon import SQLTABLE
import random

SQL_DIALECTS = {'memcache': {
Expand Down Expand Up @@ -766,10 +767,10 @@ def __str__(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():
Expand Down
36 changes: 18 additions & 18 deletions gluon/dal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1468,7 +1468,7 @@ def rowslice(self, rows, minimum=0, maximum=None):
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):
Expand Down Expand Up @@ -3891,7 +3891,7 @@ def connect(uri=self.uri,m=m):
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)


Expand Down Expand Up @@ -4182,7 +4182,7 @@ def BELONGS(self, first, second):
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):
Expand Down Expand Up @@ -4252,32 +4252,32 @@ def GE(self,first,second=None):
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):
Expand Down Expand Up @@ -4311,7 +4311,7 @@ def BELONGS(self, first, second):
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
Expand Down Expand Up @@ -4390,36 +4390,36 @@ def GE(self,first,second=None):

#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?
Expand Down
4 changes: 3 additions & 1 deletion gluon/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion gluon/sqlhtml.py
Original file line number Diff line number Diff line change
Expand Up @@ -1606,7 +1606,7 @@ def buttons(edit=False,view=False,record=None):
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:
Expand Down

0 comments on commit 01b09a4

Please sign in to comment.