Compare commits

..

7 Commits

Author SHA1 Message Date
mdipierro
b0f6dc4e16 R-2.6.2 2013-09-13 17:44:01 -05:00
mdipierro
1499b19575 R-2.6.2 2013-09-13 17:41:13 -05:00
mdipierro
877b867cef Merge pull request #212 from niphlod/fix/js_punctuation
never got to understand ASI. Let's behave and have a semicolon.
2013-09-13 15:27:46 -07:00
niphlod
837808bd77 never got to understand ASI. Let's behave and have a semicolon. 2013-09-14 00:22:53 +02:00
mdipierro
10a69f4338 removed circular import for validators 2013-09-13 17:14:47 -05:00
mdipierro
7bc603f380 fixed Pointless to set session.flash before session.renew, thanks nursix 2013-09-13 15:41:58 -05:00
mdipierro
6c1cc6fc96 tabs -> spaces 2013-09-13 15:39:39 -05:00
34 changed files with 145 additions and 145 deletions

View File

@@ -30,7 +30,7 @@ update:
echo "remember that pymysql was tweaked"
src:
### Use semantic versioning
echo 'Version 2.6.1-stable+timestamp.'`date +%Y.%m.%d.%H.%M.%S` > VERSION
echo 'Version 2.6.2-stable+timestamp.'`date +%Y.%m.%d.%H.%M.%S` > VERSION
### rm -f all junk files
make clean
### clean up baisc apps

View File

@@ -1 +1 @@
Version 2.6.1-stable+timestamp.2013.09.12.17.08.08
Version 2.6.2-stable+timestamp.2013.09.13.17.43.10

View File

@@ -50,7 +50,7 @@ if request.function == 'manage':
auth.requires_membership(manager_role)(lambda: None)()
menu = False
elif (request.application == 'admin' and not session.authorized) or \
(request.application != 'admin' and not gluon.fileutils.check_credentials(request)):
(request.application != 'admin' and not gluon.fileutils.check_credentials(request)):
redirect(URL('admin', 'default', 'index',
vars=dict(send=URL(args=request.args, vars=request.vars))))
else:
@@ -540,30 +540,30 @@ def table_template(table):
def bg_graph_model():
graph = pgv.AGraph(layout='dot', directed=True, strict=False, rankdir='LR')
subgraphs = dict()
subgraphs = dict()
for tablename in db.tables:
if hasattr(db[tablename],'_meta_graphmodel'):
meta_graphmodel = db[tablename]._meta_graphmodel
else:
meta_graphmodel = dict(group='Undefined', color='#ECECEC')
group = meta_graphmodel['group'].replace(' ', '')
group = meta_graphmodel['group'].replace(' ', '')
if not subgraphs.has_key(group):
subgraphs[group] = dict(meta=meta_graphmodel, tables=[])
subgraphs[group]['tables'].append(tablename)
else:
subgraphs[group]['tables'].append(tablename)
subgraphs[group]['tables'].append(tablename)
graph.add_node(tablename, name=tablename, shape='plaintext',
label=table_template(tablename))
for n, key in enumerate(subgraphs.iterkeys()):
for n, key in enumerate(subgraphs.iterkeys()):
graph.subgraph(nbunch=subgraphs[key]['tables'],
name='cluster%d' % n,
style='filled',
color=subgraphs[key]['meta']['color'],
label=subgraphs[key]['meta']['group'])
label=subgraphs[key]['meta']['group'])
for tablename in db.tables:
for field in db[tablename]:
@@ -580,14 +580,14 @@ def bg_graph_model():
#return graph.draw(format='png', prog='dot')
if not request.args:
return graph.draw(format='png', prog='dot')
else:
else:
response.headers['Content-Disposition']='attachment;filename=graph.%s'%request.args(0)
if request.args(0) == 'dot':
if request.args(0) == 'dot':
return graph.string()
else:
return graph.draw(format=request.args(0), prog='dot')
def graph_model():
def graph_model():
return dict(databases=databases, pgv=pgv)
def manage():

View File

@@ -212,7 +212,7 @@ def toggle_breakpoint():
except Exception, e:
session.flash = str(e)
return response.json({'ok': ok, 'lineno': lineno})
def list_breakpoints():
"Return a list of linenumbers for current breakpoints"
@@ -234,4 +234,3 @@ def list_breakpoints():
session.flash = str(e)
ok = False
return response.json({'ok': ok, 'breakpoints': breakpoints})

View File

@@ -88,7 +88,7 @@ def safe_write(a, value, b='w'):
def get_app(name=None):
app = name or request.args(0)
if (app and os.path.exists(apath(app, r=request)) and
if (app and os.path.exists(apath(app, r=request)) and
(not MULTI_USER_MODE or is_manager() or
db(db.app.name == app)(db.app.owner == auth.user.id).count())):
return app
@@ -583,11 +583,11 @@ def edit():
# show settings tab and save prefernces
if 'settings' in request.vars:
if request.post_vars: #save new preferences
if request.post_vars: #save new preferences
if config.save(request.post_vars.items()):
response.headers["web2py-component-flash"] = T('Preferences saved correctly')
else:
response.headers["web2py-component-flash"] = T('Preferences saved on session only')
response.headers["web2py-component-flash"] = T('Preferences saved on session only')
response.headers["web2py-component-command"] = "update_theme('%s'); jQuery('a[href=#editor_settings] button.close').click();" % config.read()['theme']
return
else:

View File

@@ -0,0 +1,6 @@
[DEFAULT]
theme = web2py
[editor]
theme = night

View File

@@ -179,7 +179,7 @@
});
var datetime_format = (typeof w2p_ajax_datetime_format != 'undefined') ? w2p_ajax_datetime_format : "%Y-%m-%d %H:%M:%S";
doc.on('click', "input.datetime", function () {
var tformat = $(this).data('w2p_datetime_format')
var tformat = $(this).data('w2p_datetime_format');
var active = $(this).data('w2p_datetime');
var format = (typeof tformat != 'undefined') ? tformat : datetime_format;
if(active === undefined) {
@@ -196,7 +196,7 @@
});
var date_format = (typeof w2p_ajax_date_format != 'undefined') ? w2p_ajax_date_format : "%Y-%m-%d";
doc.on('click', "input.date", function () {
var tformat = $(this).data('w2p_date_format')
var tformat = $(this).data('w2p_date_format');
var active = $(this).data('w2p_date');
var format = (typeof tformat != 'undefined') ? tformat : date_format;
if(active === undefined) {

View File

@@ -50,7 +50,7 @@ if request.function == 'manage':
auth.requires_membership(manager_role)(lambda: None)()
menu = False
elif (request.application == 'admin' and not session.authorized) or \
(request.application != 'admin' and not gluon.fileutils.check_credentials(request)):
(request.application != 'admin' and not gluon.fileutils.check_credentials(request)):
redirect(URL('admin', 'default', 'index',
vars=dict(send=URL(args=request.args, vars=request.vars))))
else:
@@ -540,30 +540,30 @@ def table_template(table):
def bg_graph_model():
graph = pgv.AGraph(layout='dot', directed=True, strict=False, rankdir='LR')
subgraphs = dict()
subgraphs = dict()
for tablename in db.tables:
if hasattr(db[tablename],'_meta_graphmodel'):
meta_graphmodel = db[tablename]._meta_graphmodel
else:
meta_graphmodel = dict(group='Undefined', color='#ECECEC')
group = meta_graphmodel['group'].replace(' ', '')
group = meta_graphmodel['group'].replace(' ', '')
if not subgraphs.has_key(group):
subgraphs[group] = dict(meta=meta_graphmodel, tables=[])
subgraphs[group]['tables'].append(tablename)
else:
subgraphs[group]['tables'].append(tablename)
subgraphs[group]['tables'].append(tablename)
graph.add_node(tablename, name=tablename, shape='plaintext',
label=table_template(tablename))
for n, key in enumerate(subgraphs.iterkeys()):
for n, key in enumerate(subgraphs.iterkeys()):
graph.subgraph(nbunch=subgraphs[key]['tables'],
name='cluster%d' % n,
style='filled',
color=subgraphs[key]['meta']['color'],
label=subgraphs[key]['meta']['group'])
label=subgraphs[key]['meta']['group'])
for tablename in db.tables:
for field in db[tablename]:
@@ -580,14 +580,14 @@ def bg_graph_model():
#return graph.draw(format='png', prog='dot')
if not request.args:
return graph.draw(format='png', prog='dot')
else:
else:
response.headers['Content-Disposition']='attachment;filename=graph.%s'%request.args(0)
if request.args(0) == 'dot':
if request.args(0) == 'dot':
return graph.string()
else:
return graph.draw(format=request.args(0), prog='dot')
def graph_model():
def graph_model():
return dict(databases=databases, pgv=pgv)
def manage():

View File

@@ -5,12 +5,12 @@ def get(args):
return None
try:
obj = globals(),get(args[0])
for k in range(1,len(args)):
for k in range(1,len(args)):
obj = getattr(obj,args[k])
return obj
except:
return None
def vars():
"""the running controller function!"""
title = '.'.join(request.args)
@@ -27,7 +27,7 @@ def vars():
d = getattr(obj,'__bases__',None)
for key in keys:
a = getattr(obj,key,None)
a = getattr(obj,key,None)
if a and not isinstance(a,DAL):
doc1 = getattr(a, '__doc__', '')
t1 = type(a)
@@ -38,7 +38,7 @@ def vars():
else:
doc = 'Unkown'
keys = []
t = c = d = None
t = c = d = None
else:
raise HTTP(400)
return dict(

View File

@@ -1,4 +1,3 @@
def hello1():
""" simple page without template """

View File

@@ -179,7 +179,7 @@
});
var datetime_format = (typeof w2p_ajax_datetime_format != 'undefined') ? w2p_ajax_datetime_format : "%Y-%m-%d %H:%M:%S";
doc.on('click', "input.datetime", function () {
var tformat = $(this).data('w2p_datetime_format')
var tformat = $(this).data('w2p_datetime_format');
var active = $(this).data('w2p_datetime');
var format = (typeof tformat != 'undefined') ? tformat : datetime_format;
if(active === undefined) {
@@ -196,7 +196,7 @@
});
var date_format = (typeof w2p_ajax_date_format != 'undefined') ? w2p_ajax_date_format : "%Y-%m-%d";
doc.on('click', "input.date", function () {
var tformat = $(this).data('w2p_date_format')
var tformat = $(this).data('w2p_date_format');
var active = $(this).data('w2p_date');
var format = (typeof tformat != 'undefined') ? tformat : date_format;
if(active === undefined) {

View File

@@ -50,7 +50,7 @@ if request.function == 'manage':
auth.requires_membership(manager_role)(lambda: None)()
menu = False
elif (request.application == 'admin' and not session.authorized) or \
(request.application != 'admin' and not gluon.fileutils.check_credentials(request)):
(request.application != 'admin' and not gluon.fileutils.check_credentials(request)):
redirect(URL('admin', 'default', 'index',
vars=dict(send=URL(args=request.args, vars=request.vars))))
else:
@@ -540,30 +540,30 @@ def table_template(table):
def bg_graph_model():
graph = pgv.AGraph(layout='dot', directed=True, strict=False, rankdir='LR')
subgraphs = dict()
subgraphs = dict()
for tablename in db.tables:
if hasattr(db[tablename],'_meta_graphmodel'):
meta_graphmodel = db[tablename]._meta_graphmodel
else:
meta_graphmodel = dict(group='Undefined', color='#ECECEC')
group = meta_graphmodel['group'].replace(' ', '')
group = meta_graphmodel['group'].replace(' ', '')
if not subgraphs.has_key(group):
subgraphs[group] = dict(meta=meta_graphmodel, tables=[])
subgraphs[group]['tables'].append(tablename)
else:
subgraphs[group]['tables'].append(tablename)
subgraphs[group]['tables'].append(tablename)
graph.add_node(tablename, name=tablename, shape='plaintext',
label=table_template(tablename))
for n, key in enumerate(subgraphs.iterkeys()):
for n, key in enumerate(subgraphs.iterkeys()):
graph.subgraph(nbunch=subgraphs[key]['tables'],
name='cluster%d' % n,
style='filled',
color=subgraphs[key]['meta']['color'],
label=subgraphs[key]['meta']['group'])
label=subgraphs[key]['meta']['group'])
for tablename in db.tables:
for field in db[tablename]:
@@ -580,14 +580,14 @@ def bg_graph_model():
#return graph.draw(format='png', prog='dot')
if not request.args:
return graph.draw(format='png', prog='dot')
else:
else:
response.headers['Content-Disposition']='attachment;filename=graph.%s'%request.args(0)
if request.args(0) == 'dot':
if request.args(0) == 'dot':
return graph.string()
else:
return graph.draw(format=request.args(0), prog='dot')
def graph_model():
def graph_model():
return dict(databases=databases, pgv=pgv)
def manage():

View File

@@ -31,7 +31,7 @@ def user():
http://..../[app]/default/user/profile
http://..../[app]/default/user/retrieve_password
http://..../[app]/default/user/change_password
http://..../[app]/default/user/manage_users (requires membership in
http://..../[app]/default/user/manage_users (requires membership in
use @auth.requires_login()
@auth.requires_membership('group name')
@auth.requires_permission('read','table name',record_id)

View File

@@ -179,7 +179,7 @@
});
var datetime_format = (typeof w2p_ajax_datetime_format != 'undefined') ? w2p_ajax_datetime_format : "%Y-%m-%d %H:%M:%S";
doc.on('click', "input.datetime", function () {
var tformat = $(this).data('w2p_datetime_format')
var tformat = $(this).data('w2p_datetime_format');
var active = $(this).data('w2p_datetime');
var format = (typeof tformat != 'undefined') ? tformat : datetime_format;
if(active === undefined) {
@@ -196,7 +196,7 @@
});
var date_format = (typeof w2p_ajax_date_format != 'undefined') ? w2p_ajax_date_format : "%Y-%m-%d";
doc.on('click', "input.date", function () {
var tformat = $(this).data('w2p_date_format')
var tformat = $(this).data('w2p_date_format');
var active = $(this).data('w2p_date');
var format = (typeof tformat != 'undefined') ? tformat : date_format;
if(active === undefined) {

View File

@@ -47,7 +47,7 @@ class MemcacheClient(object):
value = obj[1] + value
self.client.set(key, (time.time(), value))
return value
def incr(self, key, value=1):
return self.increment(key, value)

View File

@@ -9,7 +9,7 @@
Note: This module is intended as a plugin replacement of pbkdf2.py
by Armin Ronacher.
Git repository:
Git repository:
$ git clone https://github.com/michele-comitini/pbkdf2_ctypes.git
:copyright: Copyright (c) 2013: Michele Comitini <mcm@glisco.it>
@@ -79,7 +79,7 @@ def openssl_hashlib_to_crypto_map_get(hashfunc):
crypto_hashfunc.restype = ctypes.c_void_p
return crypto_hashfunc()
def openssl_pbkdf2(data, salt, iterations, digest, keylen):
"""OpenSSL compatibile wrapper
"""
@@ -92,7 +92,7 @@ def openssl_pbkdf2(data, salt, iterations, digest, keylen):
c_iter = ctypes.c_int(iterations)
c_keylen = ctypes.c_int(keylen)
c_buff = ctypes.create_string_buffer(keylen)
# PKCS5_PBKDF2_HMAC(const char *pass, int passlen,
# const unsigned char *salt, int saltlen, int iter,
# const EVP_MD *digest,
@@ -102,7 +102,7 @@ def openssl_pbkdf2(data, salt, iterations, digest, keylen):
ctypes.c_char_p, ctypes.c_int,
ctypes.c_int, ctypes.c_void_p,
ctypes.c_int, ctypes.c_char_p]
crypto.PKCS5_PBKDF2_HMAC.restype = ctypes.c_int
err = crypto.PKCS5_PBKDF2_HMAC(c_pass, c_passlen,
c_salt, c_saltlen,

View File

@@ -46,7 +46,7 @@ class PDF(object):
canvas.setLineWidth(4)
canvas.line(0, -1.25 * cm, 21.7 * cm, -1.25 * cm)
canvas.restoreState()
canvas.saveState()
notes = listify(invoice.get('notes',''))
textobject = canvas.beginText(1 * cm, -25 * cm)
@@ -57,7 +57,7 @@ class PDF(object):
textobject.textLine('Pag.%s/%s' % (page+1,pages))
canvas.drawText(textobject)
canvas.restoreState()
canvas.saveState()
business_details = listify(invoice.get('from','FROM:'))
canvas.setFont(self.font_face, 9)
@@ -66,13 +66,13 @@ class PDF(object):
textobject.textLine(line)
canvas.drawText(textobject)
canvas.restoreState()
canvas.saveState()
client_info = listify(invoice.get('to','TO:'))
textobject = canvas.beginText(1.5 * cm, -2.5 * cm)
for line in client_info:
textobject.textLine(line)
canvas.drawText(textobject)
canvas.drawText(textobject)
canvas.restoreState()
textobject = canvas.beginText(1.5 * cm, -6.75 * cm)
@@ -86,7 +86,7 @@ class PDF(object):
data = [invoice_items[0]]
for item in items:
data.append([
self.format_currency(x)
self.format_currency(x)
if isinstance(x,float) else x
for x in item])
righta = [k for k,v in enumerate(items[0])
@@ -116,10 +116,10 @@ class PDF(object):
data = [invoice['totals'][0]]
for item in items:
data.append([
self.format_currency(x)
self.format_currency(x)
if isinstance(x,float) else x
for x in item])
righta = [k for k,v in enumerate(items[0])
righta = [k for k,v in enumerate(items[0])
if isinstance(v,(int,float,Decimal))]
total = self.format_currency(invoice['total'])
data.append(['']*(len(items[0])-1)+[total])

View File

@@ -90,13 +90,13 @@ def populate(table, n=None, default=True, compute=False, contents={}):
can be used in two ways:
>>> populate(db.tablename, n=100)
or
or
>>> for k,row in enumerate(populate(db.tablename)): print row
"""
generator = populate_generator(table, default=default,
generator = populate_generator(table, default=default,
compute=compute, contents=contents)
if n is not None:
for k,record in enumerate(generator):
@@ -246,8 +246,8 @@ def populate_generator(table, default=True, compute=False, contents={}):
record[fieldname] = random.choice(LAST_NAMES)
elif fieldname.find('username')>=0:
record[fieldname] = random.choice(FIRST_NAMES).lower()+str(random.randint(1000,9999))
else:
record[fieldname] = random.choice(FIRST_NAMES)+' '+random.choice(LAST_NAMES)
else:
record[fieldname] = random.choice(FIRST_NAMES)+' '+random.choice(LAST_NAMES)
elif fieldname.find('phone')>=0:
record[fieldname] = '(%s%s%s) %s%s%s-%s%s%s%s' % (
random.choice('1234567890'),random.choice('1234567890'),random.choice('1234567890'),random.choice('1234567890'),random.choice('1234567890'),random.choice('1234567890'),random.choice('1234567890'),random.choice('1234567890'),random.choice('1234567890'),random.choice('1234567890'))

View File

@@ -244,7 +244,7 @@ def run(history, statement, env={}):
for name, val in statement_module.__dict__.items():
if name not in old_globals or represent(val) != old_globals[name]:
new_globals[name] = val
if True in [isinstance(val, tuple(UNPICKLABLE_TYPES))
for val in new_globals.values()]:
# this statement added an unpicklable global. store the statement and

View File

@@ -65,7 +65,7 @@ class Stripe:
def refund(self, charge_id):
params = urllib.urlencode({})
u = urllib.urlopen(self.URL_REFUND % (self.key, charge_id),
u = urllib.urlopen(self.URL_REFUND % (self.key, charge_id),
params)
return simplejson.loads(u.read())

View File

@@ -123,7 +123,7 @@ class WebClient(object):
else:
self.method = 'GET' if method=='auto' else method
data = None
t0 = time.time()
t0 = time.time()
self.response = opener.open(self.url, data)
self.time = time.time() - t0
except urllib2.HTTPError, error:

View File

@@ -234,12 +234,6 @@ except ImportError:
except ImportError:
simplejson = None
try:
from gluon import validators
have_validators = True
except (ImportError, SyntaxError):
have_validators = False
LOGGER = logging.getLogger("web2py.dal")
DEFAULT = lambda:0
@@ -1085,7 +1079,7 @@ class BaseAdapter(ConnectionPool):
elif not key in sql_fields:
del sql_fields_current[key]
ftype = sql_fields_old[key]['type']
if (self.dbengine in ('postgres',) and
if (self.dbengine in ('postgres',) and
ftype.startswith('geometry')):
geotype, parms = ftype[:-1].split('(')
schema = parms.split(',')[0]
@@ -1095,7 +1089,7 @@ class BaseAdapter(ConnectionPool):
elif self.dbengine in ('firebird',):
query = ['ALTER TABLE %s DROP %s;' % (tablename, key)]
else:
query = ['ALTER TABLE %s DROP COLUMN %s;' %
query = ['ALTER TABLE %s DROP COLUMN %s;' %
(tablename, key)]
metadata_change = True
elif sql_fields[key]['sql'] != sql_fields_old[key]['sql'] \
@@ -1135,9 +1129,9 @@ class BaseAdapter(ConnectionPool):
self.log('faked!\n', table)
else:
self.execute(sub_query)
# Caveat: mysql, oracle and firebird
# Caveat: mysql, oracle and firebird
# do not allow multiple alter table
# in one transaction so we must commit
# in one transaction so we must commit
# partial transactions and
# update table._dbt after alter table.
if db._adapter.commit_on_alter_table:
@@ -1790,7 +1784,7 @@ class BaseAdapter(ConnectionPool):
return self.connection.rollback()
def close_connection(self):
if self.connection:
if self.connection:
r = self.connection.close()
self.connection = None
return r
@@ -4418,7 +4412,7 @@ class GoogleSQLAdapter(UseDatabaseStoredFile,MySQLAdapter):
def find_driver(self,adapter_args,uri=None):
self.adapter_args = adapter_args
self.driver = "google"
self.driver = "google"
class NoSQLAdapter(BaseAdapter):
can_select_for_update = False
@@ -5372,7 +5366,7 @@ class MongoDBAdapter(NoSQLAdapter):
d = datetime.date(2000, 1, 1)
# mongodb doesn't has a time object and so it must datetime,
# string or integer
return datetime.datetime.combine(d, value)
return datetime.datetime.combine(d, value)
elif fieldtype == "blob":
from bson import Binary
if not isinstance(value, Binary):
@@ -6872,7 +6866,9 @@ def sqlhtml_validators(field):
fieldtype
"""
db = field.db
if not have_validators:
try:
from gluon import validators
except ImportError:
return []
field_type, field_length = field.type, field.length
if isinstance(field_type, SQLCustomType):
@@ -6938,14 +6934,14 @@ def sqlhtml_validators(field):
refs = reduce(lambda a,b:a&b, [count(ids[i:i+30]) for i in rx])
else:
refs = db(id.belongs(ids)).select(id)
return (refs and ', '.join(f(r,x.id) for x in refs) or '')
return (refs and ', '.join(f(r,x.id) for x in refs) or '')
field.represent = field.represent or list_ref_repr
if hasattr(referenced, '_format') and referenced._format:
requires = validators.IS_IN_DB(db,referenced._id,
referenced._format,multiple=True)
else:
requires = validators.IS_IN_DB(db,referenced._id,
multiple=True)
multiple=True)
if field.unique:
requires._and = validators.IS_NOT_IN_DB(db,field)
if not field.notnull:
@@ -8349,10 +8345,10 @@ class Table(object):
self._id = field
for field in fields:
if isinstance(field, (FieldMethod, FieldVirtual)):
virtual_fields.append(field)
virtual_fields.append(field)
elif isinstance(field, Field) and not field.name in fieldnames:
if field.db is not None:
field = copy.copy(field)
field = copy.copy(field)
include_new(field)
elif isinstance(field, dict) and not field['fieldname'] in fieldnames:
include_new(Field(**field))
@@ -8914,7 +8910,7 @@ class Table(object):
except ValueError:
raise RuntimeError("Unable to parse line:%s field:%s value:'%s'"
% (lineno+1,field,line[i]))
if not (id_map or cid is None or id_offset is None or unique_idx):
csv_id = long(line[cid])
curr_id = self.insert(**dict(items))
@@ -9613,7 +9609,7 @@ class Field(Expression):
else:
filename = name
# ## if file is in DB
if isinstance(self_uploadfield, (str, Field)):
if isinstance(self_uploadfield, (str, Field)):
return dict(path=None,filename=filename)
# ## if file is on filesystem
if not path:
@@ -10422,24 +10418,24 @@ class Rows(object):
one_result = False
if 'one_result' in args:
one_result = args['one_result']
def build_fields_struct(row, fields, num, groups):
''' helper function:
''' helper function:
'''
if num > len(fields)-1:
if one_result:
return row
else:
return [row]
key = fields[num]
value = row[key]
if value not in groups:
groups[value] = build_fields_struct(row, fields, num+1, {})
else:
struct = build_fields_struct(row, fields, num+1, groups[ value ])
# still have more grouping to do
if type(struct) == type(dict()):
groups[value].update()
@@ -10449,22 +10445,22 @@ class Rows(object):
# no more grouping, first only on
else:
groups[value] = struct
return groups
if len(fields) == 0:
return self
# if select returned no results
if not self.records:
return {}
grouped_row_group = dict()
# build the struct
for row in self:
build_fields_struct(row, fields, 0, grouped_row_group)
return grouped_row_group
def render(self, i=None, fields=None):

View File

@@ -1484,7 +1484,7 @@ class A(DIV):
if not self['_disable_with']:
self['_data-w2p_disable_with'] = 'default'
if self['callback'] and not self['_id']:
self['_id'] = web2py_uuid()
self['_id'] = web2py_uuid()
if self['delete']:
self['_data-w2p_remove'] = self['delete']
if self['target']:

View File

@@ -453,7 +453,7 @@ def wsgibase(environ, responder):
serve_controller(request, response, session)
except HTTP, http_response:
if static_file:
return http_response.to(responder, env=env)
@@ -470,7 +470,7 @@ def wsgibase(environ, responder):
# ##################################################
# on success, commit database
# ##################################################
if response.do_not_commit is True:
BaseAdapter.close_all_instances(None)
elif response.custom_commit:
@@ -489,7 +489,7 @@ def wsgibase(environ, responder):
if request.cid:
http_response.headers.setdefault(
'web2py-component-content', 'replace')
if request.ajax:
if response.flash:
http_response.headers['web2py-component-flash'] = \
@@ -498,7 +498,7 @@ def wsgibase(environ, responder):
if response.js:
http_response.headers['web2py-component-command'] = \
urllib2.quote(response.js.replace('\n',''))
# ##################################################
# store cookies in headers
# ##################################################

View File

@@ -48,7 +48,7 @@ class TicketStorage(Storage):
self._store_on_disk(request, ticket_id, ticket_data)
def _store_in_db(self, request, ticket_id, ticket_data):
self.db._adapter.reconnect()
self.db._adapter.reconnect()
try:
table = self._get_table(self.db, self.tablename, request.application)
id = table.insert(ticket_id=ticket_id,

View File

@@ -244,15 +244,15 @@ def try_rewrite_on_error(http_response, request, environ, ticket=None):
url = path_info + '?' + query_string
message = 'You are being redirected <a href="%s">here</a>'
return HTTP(303, message % url, Location=url), environ
elif not environ.get('__ROUTES_ONERROR__', False):
# wsgibase will be called recursively with
elif not environ.get('__ROUTES_ONERROR__', False):
# wsgibase will be called recursively with
# the routes_onerror path.
environ['__ROUTES_ONERROR__'] = True # limit recursion
path_info = '/' + path_info.lstrip('/')
environ['PATH_INFO'] = path_info
environ['QUERY_STRING'] = query_string
path_info = '/' + path_info.lstrip('/')
environ['PATH_INFO'] = path_info
environ['QUERY_STRING'] = query_string
environ['WEB2PY_STATUS_CODE'] = status
return None, environ
return None, environ
# do nothing!
return http_response, environ

View File

@@ -137,12 +137,12 @@ def env(
for k, v in extra_request.items():
request[k] = v
path_info = '/%s/%s/%s' % (a, c, f)
if request.args:
path_info = '%s/%s' % (path_info, '/'.join(request.args))
if request.vars:
vars = ['%s=%s' % (k,v) if v else '%s' % k
vars = ['%s=%s' % (k,v) if v else '%s' % k
for (k,v) in request.vars.iteritems()]
path_info = '%s?%s' % (path_info, '&'.join(vars))
request.env.path_info = path_info
@@ -238,7 +238,7 @@ def run(
pyfile = os.path.join('applications', a, 'controllers', c + '.py')
pycfile = os.path.join('applications', a, 'compiled',
"controllers_%s_%s.pyc" % (c, f))
if ((cronjob and os.path.isfile(pycfile))
if ((cronjob and os.path.isfile(pycfile))
or not os.path.isfile(pyfile)):
exec read_pyc(pycfile) in _env
elif os.path.isfile(pyfile):
@@ -425,7 +425,7 @@ def execute_from_command_line(argv=None):
parser = optparse.OptionParser(usage=get_usage())
parser.add_option('-S', '--shell', dest='shell', metavar='APPNAME',
help='run web2py in interactive shell ' +
help='run web2py in interactive shell ' +
'or IPython(if installed) with specified appname')
msg = 'run web2py in interactive shell or bpython (if installed) with'
msg += ' specified appname (if app does not exist it will be created).'

View File

@@ -434,7 +434,7 @@ class TemplateParser(object):
# Get the filename; filename looks like ``"template.html"``.
# We need to eval to remove the quotes and get the string type.
filename = eval(filename, context)
# Allow empty filename for conditional extend and include directives.
if not filename:
return ''

View File

@@ -114,7 +114,7 @@ class TestRoutes(unittest.TestCase):
except AttributeError:
pass
"""
# outgoing
# outgoing
self.assertEqual(filter_url('http://domain.com/init/default/index',
out=True), '/init/default/index')
self.assertEqual(filter_url('http://domain.com/init/default/index/arg1', out=True), '/init/default/index/arg1')

View File

@@ -120,7 +120,7 @@ class TestWeb(LiveTest):
# check registration and login were successful
client.get('index')
# COMMENTED BECAUSE FAILS BUT WHY?
self.assertTrue('Welcome Homer' in client.text)

View File

@@ -921,7 +921,7 @@ class Auth(object):
username_case_sensitive=True,
update_fields = ['email'],
ondelete="CASCADE",
client_side = True,
client_side = True,
renew_session_onlogin=True,
renew_session_onlogout=True,
keep_session_onlogin=True,
@@ -1560,8 +1560,8 @@ class Auth(object):
current_record.replace('_',' ').title())
for table in tables:
fieldnames = table.fields()
if ('id' in fieldnames and
'modified_on' in fieldnames and
if ('id' in fieldnames and
'modified_on' in fieldnames and
not current_record in fieldnames):
table._enable_record_versioning(
archive_db=archive_db,
@@ -2167,17 +2167,17 @@ class Auth(object):
elif 'username' in table_user.fields:
username = 'username'
else:
username = 'email'
username = 'email'
settings = self.settings
if 'username' in table_user.fields or \
not settings.login_email_validate:
tmpvalidator = IS_NOT_EMPTY(error_message=self.messages.is_empty)
if not settings.username_case_sensitive:
tmpvalidator = [IS_LOWER(), tmpvalidator]
tmpvalidator = [IS_LOWER(), tmpvalidator]
else:
tmpvalidator = IS_EMAIL(error_message=self.messages.invalid_email)
if not settings.email_case_sensitive:
tmpvalidator = [IS_LOWER(), tmpvalidator]
tmpvalidator = [IS_LOWER(), tmpvalidator]
old_requires = table_user[username].requires
table_user[username].requires = tmpvalidator
@@ -2191,7 +2191,7 @@ class Auth(object):
except:
pass
### use session for federated login
### use session for federated login
snext = self.get_vars_next()
if snext:
session._auth_next = snext
@@ -2414,9 +2414,9 @@ class Auth(object):
next = cas.logout_url(next)
current.session.auth = None
current.session.flash = self.messages.logged_out
if self.settings.renew_session_onlogout:
current.session.renew(clear_session=not self.settings.keep_session_onlogout)
current.session.flash = self.messages.logged_out
if not next is None:
redirect(next)
@@ -2515,9 +2515,9 @@ class Auth(object):
captcha.comment, self.settings.formstyle, 'captcha__row')
table_user.registration_key.default = key = web2py_uuid()
if form.accepts(request, session if self.csrf_prevention else None,
if form.accepts(request, session if self.csrf_prevention else None,
formname='register',
onvalidation=onvalidation,
onvalidation=onvalidation,
hideerror=self.settings.hideerror):
description = self.messages.group_description % form.vars
if self.settings.create_user_groups:
@@ -5858,7 +5858,7 @@ class Wiki(object):
class Config(object):
def __init__(
self,
filename,
filename,
section,
default_values={}
):
@@ -5879,11 +5879,11 @@ class Config(object):
def save(self, options):
for option, value in options:
self.config.set(self.section, option, value)
try:
try:
self.config.write(open(self.filename, 'w'))
result = True
except:
current.session['settings_%s' % self.section] = dict(self.config.items(self.section))
current.session['settings_%s' % self.section] = dict(self.config.items(self.section))
result = False
return result

View File

@@ -310,7 +310,7 @@ def is_loopback_ip_address(ip=None, addrinfo=None):
if not isinstance(ip, basestring):
return False
# IPv4 or IPv6-embedded IPv4 or IPv4-compatible IPv6
if ip.count('.') == 3:
if ip.count('.') == 3:
return ip.lower().startswith(('127', '::127', '0:0:0:0:0:0:127',
'::ffff:127', '0:0:0:0:0:ffff:127'))
return ip == '::1' or ip == '0:0:0:0:0:0:0:1' # IPv6 loopback
@@ -322,7 +322,7 @@ def getipaddrinfo(host):
"""
try:
return [addrinfo for addrinfo in socket.getaddrinfo(host, None)
if (addrinfo[0] == socket.AF_INET or
if (addrinfo[0] == socket.AF_INET or
addrinfo[0] == socket.AF_INET6)
and isinstance(addrinfo[4][0], basestring)]
except socket.error:

View File

@@ -3495,7 +3495,7 @@ class IS_IPV6(Validator):
('2001::8ffa:fe22:b3af', None)
>>> IS_IPV6(subnets='invalidsubnet')('2001::8ffa:fe22:b3af')
('2001::8ffa:fe22:b3af', 'invalid subnet provided')
"""
def __init__(

View File

@@ -176,7 +176,7 @@ class Web2pyCronService(Web2pyService):
from gluon.settings import global_settings
from gluon.fileutils import abspath
from os.path import exists, join
self.log('web2py Cron service starting')
if not self.chdir():
return
@@ -186,7 +186,7 @@ class Web2pyCronService(Web2pyService):
opt_mod = self._exe_args_
options = __import__(opt_mod, [], [], '')
logpath = abspath(join(options.folder, "logging.conf"))
if exists(logpath):
logging.config.fileConfig(logpath)
else: