Merge pull request #1278 from BuhtigithuB/pep8-welcome

Pep8 welcome
This commit is contained in:
mdipierro
2016-04-08 23:37:32 -05:00
4 changed files with 229 additions and 180 deletions
+7 -6
View File
@@ -1,12 +1,13 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# this file is released under public domain and you can use without limitations # this file is released under public domain and you can use without limitations
######################################################################### # -------------------------------------------------------------------------
## This is a sample controller # This is a sample controller
## - index is the default action of any application # - index is the default action of any application
## - user is required for authentication and authorization # - user is required for authentication and authorization
## - download is for downloading files uploaded in the db (does streaming) # - download is for downloading files uploaded in the db (does streaming)
######################################################################### # -------------------------------------------------------------------------
def index(): def index():
""" """
+86 -54
View File
@@ -1,60 +1,84 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
######################################################################### # -------------------------------------------------------------------------
## This scaffolding model makes your app work on Google App Engine too # This scaffolding model makes your app work on Google App Engine too
## File is released under public domain and you can use without limitations # File is released under public domain and you can use without limitations
######################################################################### # -------------------------------------------------------------------------
if request.global_settings.web2py_version < "2.14.1": if request.global_settings.web2py_version < "2.14.1":
raise HTTP(500, "Requires web2py 2.13.3 or newer") raise HTTP(500, "Requires web2py 2.13.3 or newer")
## if SSL/HTTPS is properly configured and you want all HTTP requests to # -------------------------------------------------------------------------
## be redirected to HTTPS, uncomment the line below: # if SSL/HTTPS is properly configured and you want all HTTP requests to
# be redirected to HTTPS, uncomment the line below:
# -------------------------------------------------------------------------
# request.requires_https() # request.requires_https()
## app configuration made easy. Look inside private/appconfig.ini # -------------------------------------------------------------------------
# app configuration made easy. Look inside private/appconfig.ini
# -------------------------------------------------------------------------
from gluon.contrib.appconfig import AppConfig from gluon.contrib.appconfig import AppConfig
## once in production, remove reload=True to gain full speed
# -------------------------------------------------------------------------
# once in production, remove reload=True to gain full speed
# -------------------------------------------------------------------------
myconf = AppConfig(reload=True) myconf = AppConfig(reload=True)
if not request.env.web2py_runtime_gae: if not request.env.web2py_runtime_gae:
## if NOT running on Google App Engine use SQLite or other DB # ---------------------------------------------------------------------
db = DAL(myconf.get('db.uri'), # if NOT running on Google App Engine use SQLite or other DB
pool_size = myconf.get('db.pool_size'), # ---------------------------------------------------------------------
migrate_enabled = myconf.get('db.migrate'), db = DAL(myconf.get('db.uri'),
check_reserved = ['all']) pool_size=myconf.get('db.pool_size'),
migrate_enabled=myconf.get('db.migrate'),
check_reserved=['all'])
else: else:
## connect to Google BigTable (optional 'google:datastore://namespace') # ---------------------------------------------------------------------
# connect to Google BigTable (optional 'google:datastore://namespace')
# ---------------------------------------------------------------------
db = DAL('google:datastore+ndb') db = DAL('google:datastore+ndb')
## store sessions and tickets there # ---------------------------------------------------------------------
# store sessions and tickets there
# ---------------------------------------------------------------------
session.connect(request, response, db=db) session.connect(request, response, db=db)
## or store session in Memcache, Redis, etc. # ---------------------------------------------------------------------
## from gluon.contrib.memdb import MEMDB # or store session in Memcache, Redis, etc.
## from google.appengine.api.memcache import Client # from gluon.contrib.memdb import MEMDB
## session.connect(request, response, db = MEMDB(Client())) # from google.appengine.api.memcache import Client
# session.connect(request, response, db = MEMDB(Client()))
# ---------------------------------------------------------------------
## by default give a view/generic.extension to all actions from localhost # -------------------------------------------------------------------------
## none otherwise. a pattern can be 'controller/function.extension' # by default give a view/generic.extension to all actions from localhost
# none otherwise. a pattern can be 'controller/function.extension'
# -------------------------------------------------------------------------
response.generic_patterns = ['*'] if request.is_local else [] response.generic_patterns = ['*'] if request.is_local else []
## choose a style for forms # -------------------------------------------------------------------------
# choose a style for forms
# -------------------------------------------------------------------------
response.formstyle = myconf.get('forms.formstyle') # or 'bootstrap3_stacked' or 'bootstrap2' or other response.formstyle = myconf.get('forms.formstyle') # or 'bootstrap3_stacked' or 'bootstrap2' or other
response.form_label_separator = myconf.get('forms.separator') or '' response.form_label_separator = myconf.get('forms.separator') or ''
# -------------------------------------------------------------------------
## (optional) optimize handling of static files # (optional) optimize handling of static files
# -------------------------------------------------------------------------
# response.optimize_css = 'concat,minify,inline' # response.optimize_css = 'concat,minify,inline'
# response.optimize_js = 'concat,minify,inline' # response.optimize_js = 'concat,minify,inline'
## (optional) static assets folder versioning
# -------------------------------------------------------------------------
# (optional) static assets folder versioning
# -------------------------------------------------------------------------
# response.static_version = '0.0.0' # response.static_version = '0.0.0'
#########################################################################
## Here is sample code if you need for # -------------------------------------------------------------------------
## - email capabilities # Here is sample code if you need for
## - authentication (registration, login, logout, ... ) # - email capabilities
## - authorization (role based authorization) # - authentication (registration, login, logout, ... )
## - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss) # - authorization (role based authorization)
## - old style crud actions # - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss)
## (more options discussed in gluon/tools.py) # - old style crud actions
######################################################################### # (more options discussed in gluon/tools.py)
# -------------------------------------------------------------------------
from gluon.tools import Auth, Service, PluginManager from gluon.tools import Auth, Service, PluginManager
@@ -63,10 +87,14 @@ auth = Auth(db, host_names=myconf.get('host.names'))
service = Service() service = Service()
plugins = PluginManager() plugins = PluginManager()
## create all tables needed by auth if not custom tables # -------------------------------------------------------------------------
# create all tables needed by auth if not custom tables
# -------------------------------------------------------------------------
auth.define_tables(username=False, signature=False) auth.define_tables(username=False, signature=False)
## configure email # -------------------------------------------------------------------------
# configure email
# -------------------------------------------------------------------------
mail = auth.settings.mailer mail = auth.settings.mailer
mail.settings.server = 'logging' if request.is_local else myconf.get('smtp.server') mail.settings.server = 'logging' if request.is_local else myconf.get('smtp.server')
mail.settings.sender = myconf.get('smtp.sender') mail.settings.sender = myconf.get('smtp.sender')
@@ -74,27 +102,31 @@ mail.settings.login = myconf.get('smtp.login')
mail.settings.tls = myconf.get('smtp.tls') or False mail.settings.tls = myconf.get('smtp.tls') or False
mail.settings.ssl = myconf.get('smtp.ssl') or False mail.settings.ssl = myconf.get('smtp.ssl') or False
## configure auth policy # -------------------------------------------------------------------------
# configure auth policy
# -------------------------------------------------------------------------
auth.settings.registration_requires_verification = False auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = False auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = True auth.settings.reset_password_requires_verification = True
######################################################################### # -------------------------------------------------------------------------
## Define your tables below (or better in another model file) for example # Define your tables below (or better in another model file) for example
## #
## >>> db.define_table('mytable',Field('myfield','string')) # >>> db.define_table('mytable', Field('myfield', 'string'))
## #
## Fields can be 'string','text','password','integer','double','boolean' # Fields can be 'string','text','password','integer','double','boolean'
## 'date','time','datetime','blob','upload', 'reference TABLENAME' # 'date','time','datetime','blob','upload', 'reference TABLENAME'
## There is an implicit 'id integer autoincrement' field # There is an implicit 'id integer autoincrement' field
## Consult manual for more options, validators, etc. # Consult manual for more options, validators, etc.
## #
## More API examples for controllers: # More API examples for controllers:
## #
## >>> db.mytable.insert(myfield='value') # >>> db.mytable.insert(myfield='value')
## >>> rows=db(db.mytable.myfield=='value').select(db.mytable.ALL) # >>> rows = db(db.mytable.myfield == 'value').select(db.mytable.ALL)
## >>> for row in rows: print row.id, row.myfield # >>> for row in rows: print row.id, row.myfield
######################################################################### # -------------------------------------------------------------------------
## after defining tables, uncomment below to enable auditing # -------------------------------------------------------------------------
# after defining tables, uncomment below to enable auditing
# -------------------------------------------------------------------------
# auth.enable_record_versioning(db) # auth.enable_record_versioning(db)
+121 -108
View File
@@ -1,28 +1,32 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# this file is released under public domain and you can use without limitations # this file is released under public domain and you can use without limitations
######################################################################### # ----------------------------------------------------------------------------------------------------------------------
## Customize your APP title, subtitle and menus here # Customize your APP title, subtitle and menus here
######################################################################### # ----------------------------------------------------------------------------------------------------------------------
response.logo = A(B('web',SPAN(2),'py'),XML('&trade;&nbsp;'), response.logo = A(B('web', SPAN(2), 'py'), XML('&trade;&nbsp;'),
_class="navbar-brand",_href="http://www.web2py.com/", _class="navbar-brand", _href="http://www.web2py.com/",
_id="web2py-logo") _id="web2py-logo")
response.title = request.application.replace('_',' ').title() response.title = request.application.replace('_', ' ').title()
response.subtitle = '' response.subtitle = ''
## read more at http://dev.w3.org/html5/markup/meta.name.html # ----------------------------------------------------------------------------------------------------------------------
# read more at http://dev.w3.org/html5/markup/meta.name.html
# ----------------------------------------------------------------------------------------------------------------------
response.meta.author = myconf.get('app.author') response.meta.author = myconf.get('app.author')
response.meta.description = myconf.get('app.description') response.meta.description = myconf.get('app.description')
response.meta.keywords = myconf.get('app.keywords') response.meta.keywords = myconf.get('app.keywords')
response.meta.generator = myconf.get('app.generator') response.meta.generator = myconf.get('app.generator')
## your http://google.com/analytics id # ----------------------------------------------------------------------------------------------------------------------
# your http://google.com/analytics id
# ----------------------------------------------------------------------------------------------------------------------
response.google_analytics_id = None response.google_analytics_id = None
######################################################################### # ----------------------------------------------------------------------------------------------------------------------
## this is the main application menu add/remove items as required # this is the main application menu add/remove items as required
######################################################################### # ----------------------------------------------------------------------------------------------------------------------
response.menu = [ response.menu = [
(T('Home'), False, URL('default', 'index'), []) (T('Home'), False, URL('default', 'index'), [])
@@ -30,109 +34,118 @@ response.menu = [
DEVELOPMENT_MENU = True DEVELOPMENT_MENU = True
#########################################################################
## provide shortcuts for development. remove in production # ----------------------------------------------------------------------------------------------------------------------
######################################################################### # provide shortcuts for development. remove in production
# ----------------------------------------------------------------------------------------------------------------------
def _(): def _():
# ------------------------------------------------------------------------------------------------------------------
# shortcuts # shortcuts
# ------------------------------------------------------------------------------------------------------------------
app = request.application app = request.application
ctr = request.controller ctr = request.controller
# ------------------------------------------------------------------------------------------------------------------
# useful links to internal and external resources # useful links to internal and external resources
# ------------------------------------------------------------------------------------------------------------------
response.menu += [ response.menu += [
(T('My Sites'), False, URL('admin', 'default', 'site')), (T('My Sites'), False, URL('admin', 'default', 'site')),
(T('This App'), False, '#', [ (T('This App'), False, '#', [
(T('Design'), False, URL('admin', 'default', 'design/%s' % app)), (T('Design'), False, URL('admin', 'default', 'design/%s' % app)),
LI(_class="divider"), LI(_class="divider"),
(T('Controller'), False, (T('Controller'), False,
URL( URL(
'admin', 'default', 'edit/%s/controllers/%s.py' % (app, ctr))), 'admin', 'default', 'edit/%s/controllers/%s.py' % (app, ctr))),
(T('View'), False, (T('View'), False,
URL( URL(
'admin', 'default', 'edit/%s/views/%s' % (app, response.view))), 'admin', 'default', 'edit/%s/views/%s' % (app, response.view))),
(T('DB Model'), False, (T('DB Model'), False,
URL( URL(
'admin', 'default', 'edit/%s/models/db.py' % app)), 'admin', 'default', 'edit/%s/models/db.py' % app)),
(T('Menu Model'), False, (T('Menu Model'), False,
URL( URL(
'admin', 'default', 'edit/%s/models/menu.py' % app)), 'admin', 'default', 'edit/%s/models/menu.py' % app)),
(T('Config.ini'), False, (T('Config.ini'), False,
URL( URL(
'admin', 'default', 'edit/%s/private/appconfig.ini' % app)), 'admin', 'default', 'edit/%s/private/appconfig.ini' % app)),
(T('Layout'), False, (T('Layout'), False,
URL( URL(
'admin', 'default', 'edit/%s/views/layout.html' % app)), 'admin', 'default', 'edit/%s/views/layout.html' % app)),
(T('Stylesheet'), False, (T('Stylesheet'), False,
URL( URL(
'admin', 'default', 'edit/%s/static/css/web2py-bootstrap3.css' % app)), 'admin', 'default', 'edit/%s/static/css/web2py-bootstrap3.css' % app)),
(T('Database'), False, URL(app, 'appadmin', 'index')), (T('Database'), False, URL(app, 'appadmin', 'index')),
(T('Errors'), False, URL( (T('Errors'), False, URL(
'admin', 'default', 'errors/' + app)), 'admin', 'default', 'errors/' + app)),
(T('About'), False, URL( (T('About'), False, URL(
'admin', 'default', 'about/' + app)), 'admin', 'default', 'about/' + app)),
]), ]),
('web2py.com', False, '#', [ ('web2py.com', False, '#', [
(T('Download'), False, (T('Download'), False,
'http://www.web2py.com/examples/default/download'), 'http://www.web2py.com/examples/default/download'),
(T('Support'), False, (T('Support'), False,
'http://www.web2py.com/examples/default/support'), 'http://www.web2py.com/examples/default/support'),
(T('Demo'), False, 'http://web2py.com/demo_admin'), (T('Demo'), False, 'http://web2py.com/demo_admin'),
(T('Quick Examples'), False, (T('Quick Examples'), False,
'http://web2py.com/examples/default/examples'), 'http://web2py.com/examples/default/examples'),
(T('FAQ'), False, 'http://web2py.com/AlterEgo'), (T('FAQ'), False, 'http://web2py.com/AlterEgo'),
(T('Videos'), False, (T('Videos'), False,
'http://www.web2py.com/examples/default/videos/'), 'http://www.web2py.com/examples/default/videos/'),
(T('Free Applications'), (T('Free Applications'),
False, 'http://web2py.com/appliances'), False, 'http://web2py.com/appliances'),
(T('Plugins'), False, 'http://web2py.com/plugins'), (T('Plugins'), False, 'http://web2py.com/plugins'),
(T('Recipes'), False, 'http://web2pyslices.com/'), (T('Recipes'), False, 'http://web2pyslices.com/'),
]), ]),
(T('Documentation'), False, '#', [ (T('Documentation'), False, '#', [
(T('Online book'), False, 'http://www.web2py.com/book'), (T('Online book'), False, 'http://www.web2py.com/book'),
LI(_class="divider"), LI(_class="divider"),
(T('Preface'), False, (T('Preface'), False,
'http://www.web2py.com/book/default/chapter/00'), 'http://www.web2py.com/book/default/chapter/00'),
(T('Introduction'), False, (T('Introduction'), False,
'http://www.web2py.com/book/default/chapter/01'), 'http://www.web2py.com/book/default/chapter/01'),
(T('Python'), False, (T('Python'), False,
'http://www.web2py.com/book/default/chapter/02'), 'http://www.web2py.com/book/default/chapter/02'),
(T('Overview'), False, (T('Overview'), False,
'http://www.web2py.com/book/default/chapter/03'), 'http://www.web2py.com/book/default/chapter/03'),
(T('The Core'), False, (T('The Core'), False,
'http://www.web2py.com/book/default/chapter/04'), 'http://www.web2py.com/book/default/chapter/04'),
(T('The Views'), False, (T('The Views'), False,
'http://www.web2py.com/book/default/chapter/05'), 'http://www.web2py.com/book/default/chapter/05'),
(T('Database'), False, (T('Database'), False,
'http://www.web2py.com/book/default/chapter/06'), 'http://www.web2py.com/book/default/chapter/06'),
(T('Forms and Validators'), False, (T('Forms and Validators'), False,
'http://www.web2py.com/book/default/chapter/07'), 'http://www.web2py.com/book/default/chapter/07'),
(T('Email and SMS'), False, (T('Email and SMS'), False,
'http://www.web2py.com/book/default/chapter/08'), 'http://www.web2py.com/book/default/chapter/08'),
(T('Access Control'), False, (T('Access Control'), False,
'http://www.web2py.com/book/default/chapter/09'), 'http://www.web2py.com/book/default/chapter/09'),
(T('Services'), False, (T('Services'), False,
'http://www.web2py.com/book/default/chapter/10'), 'http://www.web2py.com/book/default/chapter/10'),
(T('Ajax Recipes'), False, (T('Ajax Recipes'), False,
'http://www.web2py.com/book/default/chapter/11'), 'http://www.web2py.com/book/default/chapter/11'),
(T('Components and Plugins'), False, (T('Components and Plugins'), False,
'http://www.web2py.com/book/default/chapter/12'), 'http://www.web2py.com/book/default/chapter/12'),
(T('Deployment Recipes'), False, (T('Deployment Recipes'), False,
'http://www.web2py.com/book/default/chapter/13'), 'http://www.web2py.com/book/default/chapter/13'),
(T('Other Recipes'), False, (T('Other Recipes'), False,
'http://www.web2py.com/book/default/chapter/14'), 'http://www.web2py.com/book/default/chapter/14'),
(T('Helping web2py'), False, (T('Helping web2py'), False,
'http://www.web2py.com/book/default/chapter/15'), 'http://www.web2py.com/book/default/chapter/15'),
(T("Buy web2py's book"), False, (T("Buy web2py's book"), False,
'http://stores.lulu.com/web2py'), 'http://stores.lulu.com/web2py'),
]), ]),
(T('Community'), False, None, [ (T('Community'), False, None, [
(T('Groups'), False, (T('Groups'), False,
'http://www.web2py.com/examples/default/usergroups'), 'http://www.web2py.com/examples/default/usergroups'),
(T('Twitter'), False, 'http://twitter.com/web2py'), (T('Twitter'), False, 'http://twitter.com/web2py'),
(T('Live Chat'), False, (T('Live Chat'), False,
'http://webchat.freenode.net/?channels=web2py'), 'http://webchat.freenode.net/?channels=web2py'),
]), ]),
] ]
if DEVELOPMENT_MENU: _()
if "auth" in locals(): auth.wikimenu()
if DEVELOPMENT_MENU:
_()
if "auth" in locals():
auth.wikimenu()
+15 -12
View File
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# ----------------------------------------------------------------------------------------------------------------------
# This is an app-specific example router # This is an app-specific example router
# #
# This simple router is used for setting languages from app/languages directory # This simple router is used for setting languages from app/languages directory
@@ -8,31 +9,33 @@
# a default_language # a default_language
# #
# See <web2py-root-dir>/examples/routes.parametric.example.py for parameter's detail # See <web2py-root-dir>/examples/routes.parametric.example.py for parameter's detail
#------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------------------------------------
# To enable this route file you must do the steps: # To enable this route file you must do the steps:
#
# 1. rename <web2py-root-dir>/examples/routes.parametric.example.py to routes.py # 1. rename <web2py-root-dir>/examples/routes.parametric.example.py to routes.py
# 2. rename this APP/routes.example.py to APP/routes.py # 2. rename this APP/routes.example.py to APP/routes.py (where APP - is your application directory)
# (where APP - is your application directory) # 3. restart web2py (or reload routes in web2py admin interface)
# 3. restart web2py (or reload routes in web2py admin interfase)
# #
# YOU CAN COPY THIS FILE TO ANY APPLICATION'S ROOT DIRECTORY WITHOUT CHANGES! # YOU CAN COPY THIS FILE TO ANY APPLICATION'S ROOT DIRECTORY WITHOUT CHANGES!
# ----------------------------------------------------------------------------------------------------------------------
from fileutils import abspath from fileutils import abspath
from languages import read_possible_languages from languages import read_possible_languages
possible_languages = read_possible_languages(abspath('applications', app)) possible_languages = read_possible_languages(abspath('applications', app))
#NOTE! app - is an application based router's parameter with name of an # ----------------------------------------------------------------------------------------------------------------------
# application. E.g.'welcome' # NOTE! app - is an application based router's parameter with name of an application. E.g.'welcome'
# ----------------------------------------------------------------------------------------------------------------------
routers = { routers = {
app: dict( app: dict(
default_language = possible_languages['default'][0], default_language=possible_languages['default'][0],
languages = [lang for lang in possible_languages languages=[lang for lang in possible_languages if lang != 'default']
if lang != 'default']
) )
} }
#NOTE! To change language in your application using these rules add this line # ----------------------------------------------------------------------------------------------------------------------
#in one of your models files: # NOTE! To change language in your application using these rules add this line in one of your models files:
# ----------------------------------------------------------------------------------------------------------------------
# if request.uri_language: T.force(request.uri_language) # if request.uri_language: T.force(request.uri_language)