Merge pull request #1278 from BuhtigithuB/pep8-welcome

Pep8 welcome
This commit is contained in:
mdipierro committed 2016-04-08 23:37:32 -05:00
commit 56af81f247
4 files changed
+129 -80

No files matched your search

+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():
""" """
+82 -50
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 # ---------------------------------------------------------------------
# if NOT running on Google App Engine use SQLite or other DB
# ---------------------------------------------------------------------
db = DAL(myconf.get('db.uri'), db = DAL(myconf.get('db.uri'),
pool_size=myconf.get('db.pool_size'), pool_size=myconf.get('db.pool_size'),
migrate_enabled=myconf.get('db.migrate'), migrate_enabled=myconf.get('db.migrate'),
check_reserved=['all']) 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)
+26 -13
View File
@@ -1,9 +1,9 @@
# -*- 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/",
@@ -11,18 +11,22 @@ response.logo = A(B('web',SPAN(2),'py'),XML('&trade;&nbsp;'),
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,15 +34,20 @@ 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, '#', [
@@ -133,6 +142,10 @@ def _():
'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()
+14 -11
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)