From 6c1cc6fc96376f1943832aa032e5805436b8d6e3 Mon Sep 17 00:00:00 2001 From: mdipierro Date: Fri, 13 Sep 2013 15:39:39 -0500 Subject: [PATCH] tabs -> spaces --- VERSION | 2 +- applications/admin/controllers/appadmin.py | 26 +++++------ applications/admin/controllers/debug.py | 3 +- applications/admin/controllers/default.py | 6 +-- applications/examples/controllers/appadmin.py | 26 +++++------ applications/examples/controllers/global.py | 8 ++-- .../examples/controllers/simple_examples.py | 1 - applications/welcome/controllers/appadmin.py | 26 +++++------ applications/welcome/controllers/default.py | 2 +- gluon/contrib/gae_memcache.py | 2 +- gluon/contrib/pbkdf2_ctypes.py | 8 ++-- gluon/contrib/pdfinvoice.py | 14 +++--- gluon/contrib/populate.py | 10 ++-- gluon/contrib/shell.py | 2 +- gluon/contrib/stripe.py | 2 +- gluon/contrib/webclient.py | 2 +- gluon/dal.py | 46 +++++++++---------- gluon/html.py | 2 +- gluon/main.py | 8 ++-- gluon/restricted.py | 2 +- gluon/rewrite.py | 12 ++--- gluon/shell.py | 8 ++-- gluon/template.py | 2 +- gluon/tests/test_routes.py | 2 +- gluon/tests/test_web.py | 2 +- gluon/tools.py | 24 +++++----- gluon/utils.py | 4 +- gluon/validators.py | 2 +- gluon/winservice.py | 4 +- 29 files changed, 128 insertions(+), 130 deletions(-) diff --git a/VERSION b/VERSION index 3ae9ba00..c89eb433 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.6.1-stable+timestamp.2013.09.12.17.08.08 +Version 2.6.1-stable+timestamp.2013.09.13.15.38.54 diff --git a/applications/admin/controllers/appadmin.py b/applications/admin/controllers/appadmin.py index 2dc4a8de..505797fe 100644 --- a/applications/admin/controllers/appadmin.py +++ b/applications/admin/controllers/appadmin.py @@ -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(): diff --git a/applications/admin/controllers/debug.py b/applications/admin/controllers/debug.py index 97ef49f8..a33c0f8b 100644 --- a/applications/admin/controllers/debug.py +++ b/applications/admin/controllers/debug.py @@ -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}) - diff --git a/applications/admin/controllers/default.py b/applications/admin/controllers/default.py index 8e0120a1..2a8aae58 100644 --- a/applications/admin/controllers/default.py +++ b/applications/admin/controllers/default.py @@ -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: diff --git a/applications/examples/controllers/appadmin.py b/applications/examples/controllers/appadmin.py index 2dc4a8de..505797fe 100644 --- a/applications/examples/controllers/appadmin.py +++ b/applications/examples/controllers/appadmin.py @@ -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(): diff --git a/applications/examples/controllers/global.py b/applications/examples/controllers/global.py index 7e56902c..72b1ea17 100644 --- a/applications/examples/controllers/global.py +++ b/applications/examples/controllers/global.py @@ -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( diff --git a/applications/examples/controllers/simple_examples.py b/applications/examples/controllers/simple_examples.py index 425470ff..58a74ec2 100644 --- a/applications/examples/controllers/simple_examples.py +++ b/applications/examples/controllers/simple_examples.py @@ -1,4 +1,3 @@ - def hello1(): """ simple page without template """ diff --git a/applications/welcome/controllers/appadmin.py b/applications/welcome/controllers/appadmin.py index 2dc4a8de..505797fe 100644 --- a/applications/welcome/controllers/appadmin.py +++ b/applications/welcome/controllers/appadmin.py @@ -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(): diff --git a/applications/welcome/controllers/default.py b/applications/welcome/controllers/default.py index 4be8679f..e87dd8ec 100644 --- a/applications/welcome/controllers/default.py +++ b/applications/welcome/controllers/default.py @@ -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) diff --git a/gluon/contrib/gae_memcache.py b/gluon/contrib/gae_memcache.py index 71f7e8cf..b2508e90 100644 --- a/gluon/contrib/gae_memcache.py +++ b/gluon/contrib/gae_memcache.py @@ -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) diff --git a/gluon/contrib/pbkdf2_ctypes.py b/gluon/contrib/pbkdf2_ctypes.py index 5bb2e7dc..70c260de 100644 --- a/gluon/contrib/pbkdf2_ctypes.py +++ b/gluon/contrib/pbkdf2_ctypes.py @@ -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 @@ -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, diff --git a/gluon/contrib/pdfinvoice.py b/gluon/contrib/pdfinvoice.py index 9861d796..4c04fc0f 100644 --- a/gluon/contrib/pdfinvoice.py +++ b/gluon/contrib/pdfinvoice.py @@ -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]) diff --git a/gluon/contrib/populate.py b/gluon/contrib/populate.py index 0092ee44..122a4d64 100644 --- a/gluon/contrib/populate.py +++ b/gluon/contrib/populate.py @@ -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')) diff --git a/gluon/contrib/shell.py b/gluon/contrib/shell.py index f04a3fc4..4d206036 100755 --- a/gluon/contrib/shell.py +++ b/gluon/contrib/shell.py @@ -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 diff --git a/gluon/contrib/stripe.py b/gluon/contrib/stripe.py index 7b8c7ca8..6383f6b3 100644 --- a/gluon/contrib/stripe.py +++ b/gluon/contrib/stripe.py @@ -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()) diff --git a/gluon/contrib/webclient.py b/gluon/contrib/webclient.py index 49b7fa43..ab0828bf 100644 --- a/gluon/contrib/webclient.py +++ b/gluon/contrib/webclient.py @@ -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: diff --git a/gluon/dal.py b/gluon/dal.py index 42123993..1b33df89 100644 --- a/gluon/dal.py +++ b/gluon/dal.py @@ -1085,7 +1085,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 +1095,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 +1135,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 +1790,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 +4418,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 +5372,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): @@ -6938,14 +6938,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 +8349,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 +8914,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 +9613,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 +10422,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 +10449,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): diff --git a/gluon/html.py b/gluon/html.py index b48a77fa..94592055 100644 --- a/gluon/html.py +++ b/gluon/html.py @@ -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']: diff --git a/gluon/main.py b/gluon/main.py index 75ea6e10..d8f664ee 100644 --- a/gluon/main.py +++ b/gluon/main.py @@ -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 # ################################################## diff --git a/gluon/restricted.py b/gluon/restricted.py index 4d113a09..64e1c679 100644 --- a/gluon/restricted.py +++ b/gluon/restricted.py @@ -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, diff --git a/gluon/rewrite.py b/gluon/rewrite.py index b4f2712e..6de99861 100644 --- a/gluon/rewrite.py +++ b/gluon/rewrite.py @@ -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 here' 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 diff --git a/gluon/shell.py b/gluon/shell.py index b41a27c3..88dd6bb7 100644 --- a/gluon/shell.py +++ b/gluon/shell.py @@ -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).' diff --git a/gluon/template.py b/gluon/template.py index 03190913..c148a729 100644 --- a/gluon/template.py +++ b/gluon/template.py @@ -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 '' diff --git a/gluon/tests/test_routes.py b/gluon/tests/test_routes.py index c64da073..5b1e5f26 100644 --- a/gluon/tests/test_routes.py +++ b/gluon/tests/test_routes.py @@ -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') diff --git a/gluon/tests/test_web.py b/gluon/tests/test_web.py index 274a2cd4..a241e5ae 100644 --- a/gluon/tests/test_web.py +++ b/gluon/tests/test_web.py @@ -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) diff --git a/gluon/tools.py b/gluon/tools.py index bb9a4004..da913ed3 100644 --- a/gluon/tools.py +++ b/gluon/tools.py @@ -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 @@ -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 diff --git a/gluon/utils.py b/gluon/utils.py index 68742248..d05550b9 100644 --- a/gluon/utils.py +++ b/gluon/utils.py @@ -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: diff --git a/gluon/validators.py b/gluon/validators.py index 7e11fbbd..e833ac26 100644 --- a/gluon/validators.py +++ b/gluon/validators.py @@ -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__( diff --git a/gluon/winservice.py b/gluon/winservice.py index 0c46bcd0..765d799d 100644 --- a/gluon/winservice.py +++ b/gluon/winservice.py @@ -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: