class Mailer(Mail): def __init__(self): Mail.__init__(self) self.config = AppConfig() self.settings.tls = self.config.take('smtp.tls') self.settings.server = self.config.take('smtp.server') self.settings.sender = self.config.take('smtp.sender') if self.config.take('smtp.login'): self.settings.login = self.config.take('smtp.login') self.request = current.request
def index(): r = Rff() r.loadAppConfig() myconf = AppConfig(reload=False) client_id = myconf.take('app.clientid') client_secret = myconf.take('app.clientsecret') STATE = r.credentials['clientid'] session.state = STATE host = 'http://127.0.0.1:8000' auth_url = 'https://www.reddit.com/api/v1/authorize?client_id='+client_id+'&response_type=code&state='+STATE+'&redirect_uri='+host+URL('friends')+'&duration=temporary&scope=mysubreddits' return dict(auth_link=A('authorize',_href=auth_url))
def __init__(self, uri=None): """Initialize MongoDb Connection using PyMongo. Args: uri ([type], optional): Defaults to None. [description] """ self._uri = uri if IS_W2P_IMPORT and not uri: appconfig = AppConfig() self._uri = appconfig.get('db.uri') if self._uri: self._client = pymongo.MongoClient(self._uri) self._db = self._client.get_default_database() self._db_name = self._db.name
def __init__(self, db, auth): self.db = db self.auth = auth self.config = AppConfig() self.session = current.session self.request = current.request # Not allow self.auth.settings.actions_disabled.append("register") self.auth.settings.actions_disabled.append("request_reset_password") self.auth.settings.actions_disabled.append("retrieve_password") self.auth.settings.actions_disabled.append("profile") self.auth.settings.registration_requires_approval = False self.auth.settings.registration_requires_verification = False # Set general settings self.auth.settings.expiration = int(self.config.take("general.session_expiration")) self.auth.settings.remember_me_form = self.config.take("general.remember_me_form") if self.config.take("general.auth_type") == "ldap": self.auth.settings.login_onvalidation = [lambda form: self.__define_domain(form.vars.email.split("@")[1])] elif self.config.take("general.auth_type") == "local": if str2bool(self.config.take("auth_local.enable_change_password")) is not True: self.auth.settings.actions_disabled.append("change_password") # Disable group for each user self.auth.settings.create_user_groups = False self.auth.settings.login_next = URL("home", "index")
def __init__(self,): Mail.__init__(self) self.config = AppConfig() self.settings.tls = self.config.take("smtp.tls") self.settings.server = self.config.take("smtp.server") self.settings.sender = self.config.take("smtp.sender") if self.config.take("smtp.login"): self.settings.login = self.config.take("smtp.login") self.request = current.request
class Mailer(Mail): def __init__(self,): Mail.__init__(self) self.config = AppConfig() self.settings.tls = self.config.take("smtp.tls") self.settings.server = self.config.take("smtp.server") self.settings.sender = self.config.take("smtp.sender") if self.config.take("smtp.login"): self.settings.login = self.config.take("smtp.login") self.request = current.request def build_message_from_template(self, event_type, render_html=True, **kwargs): from gluon.html import XML from gluon.template import render path = self.request.folder + "/" + "private/email_templates/" + event_type + ".html" template = str(XML(open(path).read())) if not template: logger.warning( "App notification message, you need to define an email template for %s event \n %s" % (event_type, str(kwargs)) ) self.render = lambda text: render(text, context=dict(event_type=event_type, **kwargs)) try: if render_html: html_message = self.render(template) import html2text plain_message = html2text.html2text(html_message) except Exception as e: html_message = "" logger.warning("Render email template %s. Please, edit the email template carefully" % event_type) logger.warning(str(e)) return dict(message=[plain_message, html_message], reply_to=self.config.take("smtp.reply_to")) def send_email(self, to, subject, event_type, attachments=[], render_html=True, **kwargs): message = self.build_message_from_template(event_type, render_html, **kwargs) try: if attachments: attachment = [] for i in attachments: attachment.append(self.Attachment(i)) params = dict( to=to, subject=subject, attachments=attachment, bcc=self.config.take("smtp.bcc_to"), **message ) else: params = dict(to=to, subject=subject, bcc=self.config.take("smtp.bcc_to"), **message) sent = self.send(**params) except Exception, e: logger.error("Fail sending email to: %s" % to) logger.error(str(e)) sent = False return sent
def __init__(self, db=None, auth=None, render_view=True): self.config = AppConfig() self.auth = auth self.db = db self.render_view = render_view # In case you dont need any config or current variable if self.render_view: self._pre_render() # In case we do not need to use any database data if db: self._define_table(tables=['t_lang', 't_email_template'])
def test_appconfig(self): """ Test for the appconfig module """ from gluon import current s = Storage({'application': 'admin', 'folder': 'applications/admin'}) current.request = s simple_config = '{"config1" : "abc", "config2" : "bcd", "config3" : { "key1" : 1, "key2" : 2} }' with open('appconfig.json', 'w') as g: g.write(simple_config) myappconfig = AppConfig('appconfig.json') self.assertEqual(myappconfig['config1'], 'abc') self.assertEqual(myappconfig['config2'], 'bcd') self.assertEqual(myappconfig.take('config1'), 'abc') self.assertEqual(myappconfig.take('config3.key1', cast=str), '1') # once parsed, can't be casted to other types self.assertEqual(myappconfig.take('config3.key1', cast=int), '1') self.assertEqual(myappconfig.take('config3.key2'), 2) current.request = {}
def __init__(self, row, locale=None, type="website", url=None): """ :param row: Storage object :param locale: :param type: :param url: """ self.config = AppConfig() self.title = self.config.take('metadata.site_name') self.url = url or URL(args=current.request.args, host=True) self.type = type self.locale= locale self.row = row self.response = current.response
# -*- coding: utf-8 -*- ######################################################################### ## This scaffolding model makes your app work on Google App Engine too ## File is released under public domain and you can use without limitations ######################################################################### ## if SSL/HTTPS is properly configured and you want all HTTP requests to ## be redirected to HTTPS, uncomment the line below: # request.requires_https() ## app configuration made easy. Look inside private/appconfig.ini from gluon.contrib.appconfig import AppConfig ## once in production, remove reload=True to gain full speed myconf = AppConfig(reload=True) if not request.env.web2py_runtime_gae: ## if NOT running on Google App Engine use SQLite or other DB db = DAL(myconf.take('db.uri'), pool_size=myconf.take('db.pool_size', cast=int), check_reserved=['all']) else: ## connect to Google BigTable (optional 'google:datastore://namespace') db = DAL('google:datastore+ndb') ## store sessions and tickets there session.connect(request, response, db=db) ## or store session in Memcache, Redis, etc. ## from gluon.contrib.memdb import MEMDB ## 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
# -*- coding: utf-8 -*- # this file is released under public domain and you can use without limitations ######################################################################### ## This is a sample controller ## - index is the default action of any application ## - user is required for authentication and authorization ## - download is for downloading files uploaded in the db (does streaming) ######################################################################### if False: from gluon import * from gluon.tools import request, response, session, cache, Auth, DAL, Service, Crud, PluginManager from gluon.contrib.appconfig import AppConfig myconf = AppConfig(reload=True) db = DAL(myconf.take("db.uri"), pool_size=myconf.take("db.pool_size", cast=int), check_reserved=["all"]) # db = DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all']) auth = Auth(db) service = Service() plugins = PluginManager() def index(): """ example action using the internationalization operator T and flash rendered by views/default/index.html or views/generic.html if you need a simple wiki simply replace the two lines below with: return auth.wiki() """
import random import pytz from openstudio.os_gui import OsGui from general_helpers import represent_validity_units from general_helpers import represent_subscription_units ### Config #### # ------------------------------------------------------------------------- # app configuration made easy. Look inside private/appconfig.ini # ------------------------------------------------------------------------- from gluon.contrib.appconfig import AppConfig # ------------------------------------------------------------------------- # once in production, remove reload=True to gain full speed # ------------------------------------------------------------------------- myconf = AppConfig() ### Caching ### if myconf.get('cache.cache') == 'redis': from gluon.contrib.redis_utils import RConn from gluon.contrib.redis_cache import RedisCache redis_host = str(myconf.get('cache.redis_host')) redis_port = str(myconf.get('cache.redis_port')) rconn = RConn(redis_host, redis_port) cache.redis = RedisCache(redis_conn=rconn, debug=True) # use redis as cache cache.ram = cache.disk = cache.redis #### Custom validators begin #####
if False: # for IDEA from gluon import * request = current.request response = current.response session = current.session cache = current.cache T = current.T pass ### session is not defibed still here ## app configuration made easy. Look inside private/appconfig.ini from gluon.contrib.appconfig import AppConfig ## once in production, remove reload=True to gain full speed myconf = AppConfig(reload=True) DEVELOP = myconf.take('app.develop', cast=bool) APP_NAME = myconf.take('app.name') #response.alert = CENTER(A(B(T('Внимание! Новая Боевая среда ERM4 v.3.01.01 запущена! Скачиваем, устанавливаем и запускаем. Необходимо пересоздавать кошелек из SEED')), _href='http://datachainsworld.ru/index.php?topic=39.0', _target='blank', _style='color: red;')) response.alert = CENTER( A(B( T('Внимание! ERM4 v.3.01.07 обновление! Скачиваем, устанавливаем и запускаем.' )), _href=URL('cabinet', 'download'), _target='blank', _style='color: red;')) if request.ajax: ##session.forget(response)
# coding: utf8 from time import strptime,strftime,sleep from urllib import urlencode,urlretrieve import tmdbsimple as tmdb import os,cPickle import traceback from gluon.contrib.appconfig import AppConfig ## once in production, remove reload=True to gain full speed myconf = AppConfig(reload=False) tmdb.API_KEY = myconf.take('tmdb.key') #try: # apikey_filepath = os.path.join(request.folder, "private", "themoviedb.key") # with open(apikey_filepath, 'rb') as tmdb_api_keyfile: # TMDB_API_KEY = cPickle.load(tmdb_api_keyfile) #except: # logger.warning('Unable to load API key from %s' % apikey_filepath) #tmdb.API_KEY = TMDB_API_KEY def slugify(text): return IS_SLUG(check=False)(text.encode('utf-8'))[0] def add_person_to_db(name,tmdb_id): logger.debug('Adding %s to cast database' % name) try: p = db.moviecast.update_or_insert(nome=name,tmdb_id=tmdb_id,slug=slugify(name)) except: logger.error('Error %s to cast database' % name) return False
# File is released under public domain and you can use without limitations # ------------------------------------------------------------------------- if request.global_settings.web2py_version < "2.15.5": raise HTTP(500, "Requires web2py 2.15.5 or newer") # ------------------------------------------------------------------------- # if SSL/HTTPS is properly configured and you want all HTTP requests to # be redirected to HTTPS, uncomment the line below: # ------------------------------------------------------------------------- # request.requires_https() # ------------------------------------------------------------------------- # once in production, remove reload=True to gain full speed # ------------------------------------------------------------------------- configuration = AppConfig(reload=True) if not request.env.web2py_runtime_gae: # --------------------------------------------------------------------- # if NOT running on Google App Engine use SQLite or other DB # --------------------------------------------------------------------- db = DAL( configuration.get("db.uri"), pool_size=configuration.get("db.pool_size"), migrate_enabled=configuration.get("db.migrate"), check_reserved=["all"], ) session.connect( request, response, cookie_key=configuration.get("session.secret"),
from gluon.contrib.appconfig import AppConfig import uuid app_conf = AppConfig(reload=True) DATABASE_NAME = app_conf.take("monitutor_env.database_name") DATABASE_USER = app_conf.take("monitutor_env.database_user") DATABASE_PASSWORD = app_conf.take("monitutor_env.database_password") DATABASE_HOST = app_conf.take("monitutor_env.database_host") tutordb = DAL("postgres://" + DATABASE_USER + ":" + DATABASE_PASSWORD + "@" + DATABASE_HOST + "/" + DATABASE_NAME) from gluon.tools import Auth auth = Auth(tutordb) auth.settings.extra_fields['auth_user']= [ Field('hmac_secret', length=512, default=lambda:str(uuid.uuid4()).replace("-","")[:16]), Field('image', type='upload') ] auth.define_tables(username=True) if not tutordb.auth_group[1]: tutordb.auth_group.insert(role="admin") tutordb.define_table('monitutor_scenarios', Field('scenario_id', type='id'), Field('uuid', length=64, default=lambda:str(uuid.uuid4())), Field('name', type='string', requires=IS_ALPHANUMERIC()), Field('display_name', type='string', required=True), Field('description', type='text', required=True), Field('goal', type='text'), Field('hidden', type='boolean', default=True),
# -*- coding: utf-8 -*- ######################################################################### ## This scaffolding model makes your app work on Google App Engine too ## File is released under public domain and you can use without limitations ######################################################################### ## if SSL/HTTPS is properly configured and you want all HTTP requests to ## be redirected to HTTPS, uncomment the line below: # request.requires_https() ## app configuration made easy. Look inside private/appconfig.ini from gluon.contrib.appconfig import AppConfig ## once in production, remove reload=True to gain full speed myconf = AppConfig(reload=True) if not request.env.web2py_runtime_gae: ## if NOT running on Google App Engine use SQLite or other DB db = DAL(myconf.take('db.uri'), pool_size=myconf.take('db.pool_size', cast=int), check_reserved=['all']) else: ## connect to Google BigTable (optional 'google:datastore://namespace') db = DAL('google:datastore+ndb') ## store sessions and tickets there session.connect(request, response, db=db) ## or store session in Memcache, Redis, etc. ## from gluon.contrib.memdb import MEMDB ## from google.appengine.api.memcache import Client ## session.connect(request, response, db = MEMDB(Client()))
# -*- coding: utf-8 -*- u"""Contém as configurações do sistema. Contém configurações do sitema como conexão ao banco de dados, autenticação, linguagem e outros. """ from gluon.tools import Auth from gluon.contrib.appconfig import AppConfig from gluon import DAL, current, URL # app configuration made easy. Look inside private/appconfig.ini # once in production, remove reload=True to gain full speed myconf = AppConfig(reload=True) db = DAL( myconf.take("db.uri"), pool_size=myconf.take("db.pool_size", cast=int), check_reserved=["all"], migrate=myconf.take("db.migrate", cast=bool), ) current.response.formstyle = myconf.take("forms.formstyle") current.response.form_label_separator = myconf.take("forms.separator") # AUTH auth = Auth(db, controller="admin", function="user") # create all tables needed by auth if not custom tables auth.define_tables(username=False, signature=False)
# -*- coding: utf-8 -*- ## if SSL/HTTPS is properly configured and you want all HTTP requests to ## be redirected to HTTPS, uncomment the line below: # request.requires_https() ## get application configuration from gluon.contrib.appconfig import AppConfig ## once in production, remove reload=True to gain full speed upload_conf = AppConfig(reload=True) ## create database connection using SQLite db = DAL(upload_conf.take('db.uri'), pool_size=upload_conf.take('db.pool_size', cast=int), check_reserved=['all']) ## 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 [] ## choose a style for forms response.formstyle = upload_conf.take( 'forms.formstyle') # or 'bootstrap3_stacked' or 'bootstrap2' or other response.form_label_separator = upload_conf.take('forms.separator') ## optimize handling of static files #response.optimize_css = 'concat,minify,inline' #response.optimize_js = 'concat,minify,inline' from gluon.tools import Auth, Service, PluginManager, Recaptcha auth = Auth(db)
class Access(object): def __init__(self, db, auth): self.db = db self.auth = auth self.config = AppConfig() self.session = current.session self.request = current.request # Not allow self.auth.settings.actions_disabled.append("register") self.auth.settings.actions_disabled.append("request_reset_password") self.auth.settings.actions_disabled.append("retrieve_password") self.auth.settings.actions_disabled.append("profile") self.auth.settings.registration_requires_approval = False self.auth.settings.registration_requires_verification = False # Set general settings self.auth.settings.expiration = int(self.config.take("general.session_expiration")) self.auth.settings.remember_me_form = self.config.take("general.remember_me_form") if self.config.take("general.auth_type") == "ldap": self.auth.settings.login_onvalidation = [lambda form: self.__define_domain(form.vars.email.split("@")[1])] elif self.config.take("general.auth_type") == "local": if str2bool(self.config.take("auth_local.enable_change_password")) is not True: self.auth.settings.actions_disabled.append("change_password") # Disable group for each user self.auth.settings.create_user_groups = False self.auth.settings.login_next = URL("home", "index") def __define_domain(self, domain): domain = domain.lower() try: count = 1 while True: ldap_connection = "auth_ldap_0" + str(count) if self.config.__getattribute__(ldap_connection).is_active: if self.config.__getattribute__(ldap_connection).domain == domain: self.__load_ldap_connection(ldap_connection) break count += 1 except Exception as e: # from log import logger # logger.warning("Not possible to connect to LDAP.") raise PRETTYHTTP(400, "Upppss, the domain you have type, I could not find it...") def __load_ldap_connection(self, ldap): try: if self.config.__getattribute__(ldap).is_active: from gluon.contrib.login_methods.ldap_auth import ldap_auth if self.config.auth.auth_local_database: self.auth.settings.login_methods.append( ldap_auth( mode=self.config.__getattribute__(ldap).mode, secure=self.config.__getattribute__(ldap).secure, server=self.config.__getattribute__(ldap).server, port=self.config.__getattribute__(ldap).port, base_dn=self.config.__getattribute__(ldap).base_dn, allowed_groups=self.config.__getattribute__(ldap).allowed_groups, group_dn=self.config.__getattribute__(ldap).group_dn, group_name_attrib=self.config.__getattribute__(ldap).group_name_attrib, group_member_attrib=self.config.__getattribute__(ldap).group_member_attrib, group_filterstr=self.config.__getattribute__(ldap).group_filterstr, manage_user=True, user_firstname_attrib="cn:1", user_lastname_attrib="cn:2", user_mail_attrib="mail", db=self.db, ) ) else: self.auth.settings.login_methods = [ ( ldap_auth( mode=self.config.__getattribute__(ldap).mode, secure=self.config.__getattribute__(ldap).secure, server=self.config.__getattribute__(ldap).server, port=self.config.__getattribute__(ldap).port, base_dn=self.config.__getattribute__(ldap).base_dn, allowed_groups=self.config.__getattribute__(ldap).allowed_groups, group_dn=self.config.__getattribute__(ldap).group_dn, group_name_attrib=self.config.__getattribute__(ldap).group_name_attrib, group_member_attrib=self.config.__getattribute__(ldap).group_member_attrib, group_filterstr=self.config.__getattribute__(ldap).group_filterstr, manage_user=True, user_firstname_attrib="cn:1", user_lastname_attrib="cn:2", user_mail_attrib="mail", db=self.db, ) ) ] except Exception as e: # from log import logger # logger.warning("Not possible to connect to LDAP.") raise PRETTYHTTP(500, e)
# -*- coding: utf-8 -*- __author__ = 'Naptin' if False: from gluon import * from datetime import date, datetime from gluon.tools import request,response, session, cache, DAL,Auth, Service, PluginManager #from gluon.tools import from gluon.contrib.appconfig import AppConfig myconf = AppConfig(reload=True) db = DAL(myconf.take('db.uri'), pool_size=myconf.take('db.pool_size', cast=int), check_reserved=['all']) auth = Auth(db) service = Service() plugins = PluginManager() from db import * ## create all tables needed by auth if not custom tables #auth.define_tables(username=False, signature=False) from time import ctime db.define_table('rev_wallet', Field('revnumber', requires=IS_LENGTH(16, 16)), Field('month_issued', 'integer', requires=IS_INT_IN_RANGE(1, 12)), Field('year_issued', 'integer', requires=IS_INT_IN_RANGE(2015, 2099)), Field('month_expired', 'integer', requires=IS_INT_IN_RANGE(1, 12)), Field('year_expired', 'integer', requires=IS_INT_IN_RANGE(2015, 2099)), Field('amount', 'float'), ) db.define_table('device',
# File is released under public domain and you can use without limitations # ------------------------------------------------------------------------- # if request.global_settings.web2py_version < "2.15.5": # raise HTTP(500, "Requires web2py 2.15.5 or newer") # ------------------------------------------------------------------------- # if SSL/HTTPS is properly configured and you want all HTTP requests to # be redirected to HTTPS, uncomment the line below: # ------------------------------------------------------------------------- request.requires_https() # ------------------------------------------------------------------------- # once in production, remove reload=True to gain full speed # ------------------------------------------------------------------------- configuration = AppConfig(reload=True) if not request.env.web2py_runtime_gae: # --------------------------------------------------------------------- # if NOT running on Google App Engine use SQLite or other DB # --------------------------------------------------------------------- db = DAL('mysql://*****:*****@localhost/main?set_encoding=utf8mb4', pool_size=10, migrate=False) else: # --------------------------------------------------------------------- # connect to Google BigTable (optional 'google:datastore://namespace') # --------------------------------------------------------------------- db = DAL('google:datastore+ndb')
# -*- coding: utf-8 -*- ######################################################################### ## This scaffolding model makes your app work on Google App Engine too ## File is released under public domain and you can use without limitations ######################################################################### ## if SSL/HTTPS is properly configured and you want all HTTP requests to ## be redirected to HTTPS, uncomment the line below: # request.requires_https() ## app configuration made easy. Look inside private/appconfig.ini from gluon.contrib.appconfig import AppConfig ## once in production, remove reload=True to gain full speed myconf = AppConfig(reload=True) if not request.env.web2py_runtime_gae: ## if NOT running on Google App Engine use SQLite or other DB db = DAL( myconf.take('db.uri'), pool_size=myconf.take('db.pool_size', cast=int), check_reserved=['all']) else: ## connect to Google BigTable (optional 'google:datastore://namespace') db = DAL('google:datastore+ndb') ## store sessions and tickets there session.connect(request, response, db=db) ## or store session in Memcache, Redis, etc. ## from gluon.contrib.memdb import MEMDB
# -*- coding: utf-8 -*- ######################################################################### ## This scaffolding model makes your app work on Google App Engine too ## File is released under public domain and you can use without limitations ######################################################################### ## if SSL/HTTPS is properly configured and you want all HTTP requests to ## be redirected to HTTPS, uncomment the line below: # request.requires_https() ## app configuration made easy. Look inside private/appconfig.ini from gluon.contrib.appconfig import AppConfig ## once in production, remove reload=True to gain full speed myconf = AppConfig(reload=True) db = DAL('mysql://*****:*****@mysql.server/SlugStock$default') #if not request.env.web2py_runtime_gae: ## if NOT running on Google App Engine use SQLite or other DB #db = DAL(myconf.take('db.uri'), pool_size=myconf.take('db.pool_size', cast=int), check_reserved=['all']) #else: ## connect to Google BigTable (optional 'google:datastore://namespace') #db = DAL('google:datastore+ndb') ## store sessions and tickets there #session.connect(request, response, db=db) ## or store session in Memcache, Redis, etc. ## from gluon.contrib.memdb import MEMDB ## from google.appengine.api.memcache import Client ## session.connect(request, response, db = MEMDB(Client()))
# File is released under public domain and you can use without limitations # ------------------------------------------------------------------------- if request.global_settings.web2py_version < "2.15.5": raise HTTP(500, "Requires web2py 2.15.5 or newer") # ------------------------------------------------------------------------- # if SSL/HTTPS is properly configured and you want all HTTP requests to # be redirected to HTTPS, uncomment the line below: # ------------------------------------------------------------------------- # request.requires_https() # ------------------------------------------------------------------------- # once in production, remove reload=True to gain full speed # ------------------------------------------------------------------------- configuration = AppConfig(reload=True) if not request.env.web2py_runtime_gae: # --------------------------------------------------------------------- # if NOT running on Google App Engine use SQLite or other DB # --------------------------------------------------------------------- db = DAL('sqlite://storage.sqlite') else: # --------------------------------------------------------------------- # connect to Google BigTable (optional 'google:datastore://namespace') # --------------------------------------------------------------------- db = DAL('google:datastore+ndb') # --------------------------------------------------------------------- # store sessions and tickets there # --------------------------------------------------------------------- session.connect(request, response, db=db)
# (at your option) any later version. # # ssis_dash is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with ssis_dash. If not, see <http://www.gnu.org/licenses/>. ## app configuration made easy. Look inside private/appconfig.ini from gluon.contrib.appconfig import AppConfig ## once in production, remove reload=True to gain full speed myappconfig = AppConfig(reload=True) from gluon.tools import Auth, Service service = Service() response.generic_patterns = ["*"] if request.is_local else [] mode = myappconfig.take("ssis_dash.mode") response.formstyle = myappconfig.take("forms.formstyle") # or 'bootstrap3_stacked' or 'bootstrap2' or other response.form_label_separator = myappconfig.take("forms.separator") if mode == "protected":
# -*- coding: utf-8 -*- ######################################################################### ## This scaffolding model makes your app work on Google App Engine too ## File is released under public domain and you can use without limitations ######################################################################### ## if SSL/HTTPS is properly configured and you want all HTTP requests to ## be redirected to HTTPS, uncomment the line below: # request.requires_https() ## app configuration made easy. Look inside private/appconfig.ini from gluon.contrib.appconfig import AppConfig ## once in production, remove reload=True to gain full speed myconf = AppConfig(reload=True) 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'), pool_size = myconf.get('db.pool_size'), migrate_enabled = myconf.get('db.migrate'), check_reserved = ['all']) else: ## connect to Google BigTable (optional 'google:datastore://namespace') db = DAL('google:datastore+ndb') ## store sessions and tickets there session.connect(request, response, db=db) ## or store session in Memcache, Redis, etc. ## from gluon.contrib.memdb import MEMDB ## from google.appengine.api.memcache import Client ## session.connect(request, response, db = MEMDB(Client()))
# -*- coding: utf-8 -*- if False: from gluon import * from db import * from menu import * from tables import * from gluon.contrib.appconfig import AppConfig from gluon.tools import Auth, Service, PluginManager request = current.request response = current.response session = current.session cache = current.cache T = current.T db = DAL('sqlite://storage.sqlite') myconf = AppConfig(reload=True) auth = Auth(db) service = Service() plugins = PluginManager() from agiscore.gui.mic import MenuLateral, MenuMigas menu_lateral = MenuLateral(list()) menu_migas = MenuMigas() import datetime from gluon.storage import Storage from agiscore.gui.mic import Accion, grid_simple from agiscore.gui.evento import form_configurar_evento from agiscore.db.evento import esta_activo from agiscore.db import pais as pais_model from agiscore.db.matricula import SIN_MATRICULAR, SIN_MATRICULAR_CON_DEUDA from agiscore.db.matricula import MATRICULADO, MATRICULADO_CON_DEUDAS
from gluon.contrib.appconfig import AppConfig ## once in production, remove reload=True to gain full speed myconf = AppConfig(reload=True) db = DAL("sqlite://storage.sqlite", migrate=True)#migrate=True fake_migrate=True from gluon.tools import Auth, Service, PluginManager auth = Auth(db) service = Service() plugins = PluginManager() auth.settings.extra_fields['auth_user']= [ Field('phone_number', 'string', requires = IS_MATCH('^\d{3}-?\d{3}-?\d{4}$', error_message='example: 111-555-2345')), Field('phone_provider', 'string', requires = IS_IN_SET(('AT&T','Metro PCS','Sprint PCS', 'T-Mobile USA (tmail)', 'Verizon Wireless (vtext)', 'Virgin Mobile USA'))), Field('daily_message', 'boolean', default=False), Field('get_texts', 'boolean', default=False), Field('netWorth', 'double', writable=False,) ] ## create all tables needed by auth if not custom tables auth.define_tables(username=False, signature=False) ## configure email mail = auth.settings.mailer mail.settings.server = 'logging' if request.is_local else myconf.take('smtp.server') mail.settings.sender = myconf.take('smtp.sender') mail.settings.login = myconf.take('smtp.login') ## configure auth policy auth.settings.registration_requires_verification = False auth.settings.registration_requires_approval = False
# -*- coding: utf-8 -*- from gluon.tools import PluginManager # Remove this in production from gluon.custom_import import track_changes track_changes(True) from gluon.contrib.appconfig import AppConfig from plugin_social_auth.utils import SocialAuth myconf = AppConfig(reload=True) # This needs to be replaced by your own db connection db = DAL('sqlite://storage.sqlite') auth = SocialAuth(db) plugins = PluginManager() # Enable the "username" field auth.define_tables(username=True) # Disable certain auth actions unless you're also using web2py account registration auth.settings.actions_disabled = [ 'register', 'change_password', 'request_reset_password' ] auth.settings.logout_next = URL(args=request.args, vars=request.get_vars) # Make user props readonly since these will automatically be updated # when the user logs on with a new social account anyway. # NOTE: this fails when lazy tables used. for prop in ['first_name', 'last_name', 'username', 'email']:
# File is released under public domain and you can use without limitations # ------------------------------------------------------------------------- if request.global_settings.web2py_version < "2.15.5": raise HTTP(500, "Requires web2py 2.15.5 or newer") # ------------------------------------------------------------------------- # if SSL/HTTPS is properly configured and you want all HTTP requests to # be redirected to HTTPS, uncomment the line below: # ------------------------------------------------------------------------- # request.requires_https() # ------------------------------------------------------------------------- # once in production, remove reload=True to gain full speed # ------------------------------------------------------------------------- configuration = AppConfig(reload=True) # -----------configure mongo document_class=OrderedDict------ from pydal.adapters.mongo import Mongo from pydal.helpers.classes import FakeCursor def connector(self=Mongo): from collections import OrderedDict conn = self.driver.MongoClient(self.uri, w=self.safe, document_class=OrderedDict)[self._driver_db] conn.cursor = lambda: FakeCursor() conn.close = lambda: None conn.commit = lambda: None return conn
## This scaffolding model makes your app work on Google App Engine too ## File is released under public domain and you can use without limitations ######################################################################### ## if SSL/HTTPS is properly configured and you want all HTTP requests to ## be redirected to HTTPS, uncomment the line below: # request.requires_https() ## app configuration made easy. Look inside private/appconfig.ini if False: from gluon import * from gluon.tools import request, response, session, cache, DAL from gluon.contrib.appconfig import AppConfig myconf = AppConfig(reload=True) # db = DAL(myconf.take('db.uri'), pool_size=myconf.take('db.pool_size', cast=int), check_reserved=['all']) db = DAL("sqlite://storage.sqlite", pool_size=1, check_reserved=["all"]) # from gluon.contrib.appconfig import AppConfig ## once in production, remove reload=True to gain full speed # myconf = AppConfig(reload=True) if not request.env.web2py_runtime_gae: ## if NOT running on Google App Engine use SQLite or other DB db = DAL(myconf.take("db.uri"), pool_size=myconf.take("db.pool_size", cast=int), check_reserved=["all"]) # db = DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all']) else: ## connect to Google BigTable (optional 'google:datastore://namespace') db = DAL("google:datastore+ndb")
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ ## if SSL/HTTPS is properly configured and you want all HTTP requests to ## be redirected to HTTPS, uncomment the line below: # request.requires_https() ## app configuration made easy. Look inside private/appconfig.ini from gluon.contrib.appconfig import AppConfig from gluon.tools import Mail ## once in production, remove reload=True to gain full speed myconf = AppConfig(reload=True) if not request.env.web2py_runtime_gae: ## if NOT running on Google App Engine use SQLite or other DB db = DAL('mysql://' + current.mysql_user + \ ':' + current.mysql_password + \ '@' + current.mysql_server + \ '/' + current.mysql_dbname) # db = DAL(myconf.take('db.uri'), pool_size=myconf.take('db.pool_size', cast=int), check_reserved=['all']) else: ## connect to Google BigTable (optional 'google:datastore://namespace') db = DAL('google:datastore+ndb') ## store sessions and tickets there session.connect(request, response, db=db) ## or store session in Memcache, Redis, etc. ## from gluon.contrib.memdb import MEMDB
# -*- coding: utf-8 -*- ######################################################################### ## This scaffolding model makes your app work on Google App Engine too ## File is released under public domain and you can use without limitations ######################################################################### ## if SSL/HTTPS is properly configured and you want all HTTP requests to ## be redirected to HTTPS, uncomment the line below: # request.requires_https() ## app configuration made easy. Look inside private/appconfig.ini from gluon.contrib.appconfig import AppConfig ## once in production, remove reload=True to gain full speed myconf = AppConfig(reload=True) 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'), pool_size=myconf.get('db.pool_size'), migrate_enabled=myconf.get('db.migrate'), check_reserved=['all']) else: ## connect to Google BigTable (optional 'google:datastore://namespace') db = DAL('google:datastore+ndb') ## store sessions and tickets there session.connect(request, response, db=db) ## or store session in Memcache, Redis, etc. ## from gluon.contrib.memdb import MEMDB ## from google.appengine.api.memcache import Client ## session.connect(request, response, db = MEMDB(Client()))
# -*- coding: utf-8 -*- from random import SystemRandom # Track module changes from gluon.custom_import import track_changes; track_changes(True) from gluon import current from gluon.contrib.appconfig import AppConfig # Adjust settings depending on environment settings = dict() if request.env.http_host in ('127.0.0.1:8000', 'localhost:8000', '192.168.0.8:8000'): settings['is_development'] = True myconf = AppConfig(reload=True) else: # Production settings settings['is_development'] = False myconf = AppConfig() request.requires_https() # response.optimize_css = 'concat,minify,inline' # response.optimize_js = 'concat,minify,inline' # Setup db db = DAL( myconf.take('db.uri'), pool_size=myconf.take('db.pool_size', cast=int), check_reserved=['mysql']) db_scheduler = DAL(myconf.take('db.uri'), pool_size=myconf.take('db.pool_size', cast=int), check_reserved=['mysql']) # Add db to current current.db = db
# the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # ssis_dash is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with ssis_dash. If not, see <http://www.gnu.org/licenses/>. ## app configuration made easy. Look inside private/appconfig.ini from gluon.contrib.appconfig import AppConfig ## once in production, remove reload=True to gain full speed myappconfig = AppConfig(reload=True) from gluon.tools import Auth, Service service = Service() response.generic_patterns = ['*'] if request.is_local else [] mode = myappconfig.take('ssis_dash.mode') response.formstyle = myappconfig.take('forms.formstyle') # or 'bootstrap3_stacked' or 'bootstrap2' or other response.form_label_separator = myappconfig.take('forms.separator') if mode == 'protected':
# -*- coding: utf-8 -*- if False: from gluon import * from db import * from menu import * from tables import * from gluon.contrib.appconfig import AppConfig from gluon.tools import Auth, Service, PluginManager request = current.request response = current.response session = current.session cache = current.cache T = current.T db = DAL('sqlite://storage.sqlite') myconf = AppConfig(reload=True) auth = Auth(db) service = Service() plugins = PluginManager() from agiscore.gui.mic import MenuLateral, MenuMigas menu_lateral = MenuLateral(list()) menu_migas = MenuMigas() from gluon.storage import Storage from agiscore.gui.mic import Accion, grid_simple # TODO: remove response.menu = [] menu_lateral.append(Accion(T('Tipos de pagos'), URL('index'),
from gluon.contrib.appconfig import AppConfig ## once in production, remove reload=True to gain full speed myconf = AppConfig(reload=True) db = DAL("sqlite://storage.sqlite", migrate=True) #migrate=True fake_migrate=True from gluon.tools import Auth, Service, PluginManager auth = Auth(db) service = Service() plugins = PluginManager() auth.settings.extra_fields['auth_user'] = [ Field('phone_number', 'string', requires=IS_MATCH('^\d{3}-?\d{3}-?\d{4}$', error_message='example: 111-555-2345')), Field('phone_provider', 'string', requires=IS_IN_SET( ('AT&T', 'Metro PCS', 'Sprint PCS', 'T-Mobile USA (tmail)', 'Verizon Wireless (vtext)', 'Virgin Mobile USA'))), Field('daily_message', 'boolean', default=False), Field('get_texts', 'boolean', default=False), Field( 'netWorth', 'double', writable=False, ) ]
import sys import random import requests from gluon.contrib.appconfig import AppConfig from gluon import current myconf = AppConfig(reload=False) def upper_under(text): return text.upper().replace(' ', '_') def call(method, *args): method = 'ApiV1.' + method if '.' not in method else method try: r = requests.post(myconf.get('accurate.server'), json={ 'id': random.randint(1, sys.maxint), 'method': method, 'params': args }) except requests.exceptions.ConnectionError as e: return dict(error=str(e)) try: r.raise_for_status() except requests.exceptions.HTTPError as e: return dict(error=str(e)) try: response = r.json() except ValueError as e:
if request.global_settings.web2py_version < "2.15.5": raise HTTP(500, "Requires web2py 2.15.5 or newer") logger = logging.getLogger("web2py.app.bars") # ------------------------------------------------------------------------- # if SSL/HTTPS is properly configured and you want all HTTP requests to # be redirected to HTTPS, uncomment the line below: # ------------------------------------------------------------------------- # request.requires_https() # ------------------------------------------------------------------------- # once in production, remove reload=True to gain full speed # ------------------------------------------------------------------------- configuration = AppConfig(reload=True) if not request.env.web2py_runtime_gae: # --------------------------------------------------------------------- # if NOT running on Google App Engine use SQLite or other DB # --------------------------------------------------------------------- db = DAL(configuration.get('db.uri'), pool_size=configuration.get('db.pool_size'), migrate_enabled=configuration.get('db.migrate'), check_reserved=['all']) else: # --------------------------------------------------------------------- # connect to Google BigTable (optional 'google:datastore://namespace') # --------------------------------------------------------------------- db = DAL('google:datastore+ndb') # ---------------------------------------------------------------------
# -*- coding: utf-8 -*- from gluon.tools import Auth from gluon.tools import prettydate from gluon.contrib.appconfig import AppConfig # app configuration made easy. Look inside private/appconfig.ini # once in production, remove reload=True to gain full speed myconf = AppConfig(reload=True) db = DAL( myconf.take('db.uri'), pool_size=myconf.take('db.pool_size', cast=int), check_reserved=['all'], migrate=myconf.take('db.migrate', cast=bool) ) response.formstyle = myconf.take('forms.formstyle') response.form_label_separator = myconf.take('forms.separator') # AUTH auth = Auth(db, controller='admin', function='user') # create all tables needed by auth if not custom tables auth.define_tables(username=False, signature=False) # configure auth policy auth.settings.registration_requires_verification = False auth.settings.registration_requires_approval = False auth.settings.reset_password_requires_verification = True
# This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # # # Author Daniel J. Ramirez <*****@*****.**> from gluon import current from gluon import URL from gluon.contrib.appconfig import AppConfig ## once in production, remove reload=True to gain full speed CONF = AppConfig() # constants definitions FLOW_BASIC = 0 # seller and manager # one person list the items, other checkouts and other delivers FLOW_MULTIROLE = 1 # reduce the common employee permissions to the mimimum FLOW_IRON_FIST = 2 class AccessCard: data = {}
# ------------------------------------------------------------------------- # if SSL/HTTPS is properly configured and you want all HTTP requests to # be redirected to HTTPS, uncomment the line below: # ------------------------------------------------------------------------- # request.requires_https() # ------------------------------------------------------------------------- # app configuration made easy. Look inside private/appconfig.ini # ------------------------------------------------------------------------- from gluon.contrib.appconfig import AppConfig # ------------------------------------------------------------------------- # once in production, remove reload=True to gain full speed # ------------------------------------------------------------------------- myconf = AppConfig(reload=True) 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'), pool_size=myconf.get('db.pool_size'), migrate_enabled=myconf.get('db.migrate'), check_reserved=['all'], #fake_migrate_all=True ) else: # --------------------------------------------------------------------- # connect to Google BigTable (optional 'google:datastore://namespace') # ---------------------------------------------------------------------
# ------------------------------------------------------------------------- # if SSL/HTTPS is properly configured and you want all HTTP requests to # be redirected to HTTPS, uncomment the line below: # ------------------------------------------------------------------------- # request.requires_https() # ------------------------------------------------------------------------- # app configuration made easy. Look inside private/appconfig.ini # ------------------------------------------------------------------------- from gluon.contrib.appconfig import AppConfig # ------------------------------------------------------------------------- # once in production, remove reload=True to gain full speed # ------------------------------------------------------------------------- myconf = AppConfig(reload=True) 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"), pool_size=myconf.get("db.pool_size"), migrate_enabled=myconf.get("db.migrate"), check_reserved=["all"], ) else: # --------------------------------------------------------------------- # connect to Google BigTable (optional 'google:datastore://namespace') # ---------------------------------------------------------------------
from gluon.contrib.appconfig import AppConfig configuration = AppConfig(reload=True) db = DAL("sqlite://storage.sqlite") db.define_table("users", Field('db_firstname'), Field('db_lastname'), Field('db_email'), Field('db_password'))
# ------------------------------------------------------------------------- # if SSL/HTTPS is properly configured and you want all HTTP requests to # be redirected to HTTPS, uncomment the line below: # ------------------------------------------------------------------------- # request.requires_https() # ------------------------------------------------------------------------- # app configuration made easy. Look inside private/appconfig.ini # ------------------------------------------------------------------------- from gluon.contrib.appconfig import AppConfig # ------------------------------------------------------------------------- # once in production, remove reload=True to gain full speed # ------------------------------------------------------------------------- myconf = AppConfig(reload=True) 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'), pool_size=myconf.get('db.pool_size'), migrate_enabled=myconf.get('db.migrate')) else: # --------------------------------------------------------------------- # connect to Google BigTable (optional 'google:datastore://namespace') # --------------------------------------------------------------------- db = DAL('google:datastore+ndb') # --------------------------------------------------------------------- # store sessions and tickets there
# -*- coding: utf-8 -*- from gluon.contrib.appconfig import AppConfig from gluon.tools import Auth, Service, PluginManager import logging, sys # if request.global_settings.web2py_version < "2.15.5": # raise HTTP(500, "Requires web2py 2.15.5 or newer") # ----- configuration stuff ----- configuration = AppConfig(reload=True) if not request.env.web2py_runtime_gae: db = DAL(configuration.get('db.uri'), pool_size=configuration.get('db.pool_size'), migrate_enabled=configuration.get('db.migrate'), check_reserved=['all']) session.connect(request, response, db=db) else: db = DAL('google:datastore+ndb') session.connect(request, response, db=db) response.generic_patterns = [] if request.is_local and not configuration.get('app.production'): response.generic_patterns.append('*') response.formstyle = configuration.get('forms.formstyle') response.form_label_separator = configuration.get('forms.separator') or '' if configuration.get('scheduler.enabled'): from gluon.scheduler import Scheduler scheduler = Scheduler(db, heartbeat=configure.get('heartbeat'))
# track changes for modules from gluon.custom_import import track_changes track_changes(DEBUG) # set utc as standard time for app request.now = request.utcnow if request.global_settings.web2py_version < "2.14.1": raise HTTP(500, "Requires web2py 2.14.1 or newer") # request.requires_https() # application configuration using private/appconfig.ini from gluon.contrib.appconfig import AppConfig myconf = AppConfig(reload=DEBUG) current.myconf = myconf myconf_env = myconf.get('environment.type') current.myconf_env = myconf_env # set db connection if not request.env.web2py_runtime_gae: # if NOT running on Google App Engine use SQLite or other DB db = DAL( myconf.get(myconf_env + 'db.uri'), pool_size=myconf.get(myconf_env + 'db.pool_size'), migrate_enabled=myconf.get(myconf_env + 'db.migrate'), check_reserved=['mysql', 'postgres'], # ['all']) lazy_tables=True) else: # connect to Google BigTable (optional 'google:datastore://namespace')
# ------------------------------------------------------------------------- # if SSL/HTTPS is properly configured and you want all HTTP requests to # be redirected to HTTPS, uncomment the line below: # ------------------------------------------------------------------------- # request.requires_https() # ------------------------------------------------------------------------- # app configuration made easy. Look inside private/appconfig.ini # ------------------------------------------------------------------------- from gluon.contrib.appconfig import AppConfig # ------------------------------------------------------------------------- # once in production, remove reload=True to gain full speed # ------------------------------------------------------------------------- myconf = AppConfig(reload=True) # ------------------------------------------------------------------------- # 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 [] # ------------------------------------------------------------------------- # choose a style for forms # ------------------------------------------------------------------------- response.formstyle = myconf.get('forms.formstyle') # or 'bootstrap3_stacked' or 'bootstrap2' or other response.form_label_separator = myconf.get('forms.separator') or '' # ------------------------------------------------------------------------- # (optional) optimize handling of static files # -------------------------------------------------------------------------
"""Infrastructure to run an Web2py application under test environment. We create a temporary file to indicate the application she's running under test. By default this file is created in ramdisk (Ubuntu) to speed up execution. Web2py applications need this external injection mainly to know where to create their test database. """ import glob import os from gluon.contrib.appconfig import AppConfig myconf = AppConfig(reload=True) default_path = "/Users/adityagaykar/Documents/tmp" #default_path = "/dev/shm/web2py_test" # Ubuntu native ramdisk is faster default_filename = "web2py_test_indicator" _test_filename = None def testfile_name(appname=None): global _test_filename if _test_filename: return _test_filename path = os.path.join(default_path, appname) _test_filename = os.path.join(path, default_filename)
# ------------------------------------------------------------------------- # if SSL/HTTPS is properly configured and you want all HTTP requests to # be redirected to HTTPS, uncomment the line below: # ------------------------------------------------------------------------- # request.requires_https() db = DAL("sqlite://storage.sqlite") # ------------------------------------------------------------------------- # app configuration made easy. Look inside private/appconfig.ini # ------------------------------------------------------------------------- from gluon.contrib.appconfig import AppConfig # ------------------------------------------------------------------------- # once in production, remove reload=True to gain full speed # ------------------------------------------------------------------------- myconf = AppConfig(reload=True) 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'), pool_size=myconf.get('db.pool_size'), migrate_enabled=myconf.get('db.migrate'), check_reserved=['all']) else: # --------------------------------------------------------------------- # connect to Google BigTable (optional 'google:datastore://namespace') # --------------------------------------------------------------------- db = DAL('google:datastore+ndb') # ---------------------------------------------------------------------
# -*- coding: utf-8 -*- ######################################################################### ## This scaffolding model makes your app work on Google App Engine too ## File is released under public domain and you can use without limitations ######################################################################### ## if SSL/HTTPS is properly configured and you want all HTTP requests to ## be redirected to HTTPS, uncomment the line below: # request.requires_https() ## app configuration made easy. Look inside private/appconfig.ini from gluon.contrib.appconfig import AppConfig ## once in production, remove reload=True to gain full speed myconf = AppConfig(reload=True) # logging. import logging if request.env.web2py_runtime_gae: logger = logging else: import sys import logging, sys FORMAT = "%(asctime)s %(levelname)s %(process)s %(thread)s %(funcName)s():%(lineno)d %(message)s" logging.basicConfig(stream=sys.stderr) logger = logging.getLogger(request.application) logger.setLevel(logging.INFO) logger.info("Not on gae") from gluon import current logging = logger
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ ## if SSL/HTTPS is properly configured and you want all HTTP requests to ## be redirected to HTTPS, uncomment the line below: # request.requires_https() ## app configuration made easy. Look inside private/appconfig.ini from gluon.contrib.appconfig import AppConfig from gluon.tools import Mail import json as json_for_views ## once in production, remove reload=True to gain full speed myconf = AppConfig(reload=True) if not request.env.web2py_runtime_gae: ## if NOT running on Google App Engine use SQLite or other DB mysql_connection = 'mysql://' + current.mysql_user + \ ':' + current.mysql_password + \ '@' + current.mysql_server db = DAL(mysql_connection + '/' + current.mysql_dbname, table_hash="stopstalkdb") uvadb = DAL(mysql_connection + '/' + current.mysql_uvadbname, table_hash="uvajudge") # db = DAL(myconf.take('db.uri'), pool_size=myconf.take('db.pool_size', cast=int), check_reserved=['all']) else: ## connect to Google BigTable (optional 'google:datastore://namespace')
from gluon.storage import Storage # ------------------------------------------------------------------------- # app configuration made easy. Look inside private/appconfig.ini # ------------------------------------------------------------------------- from gluon.contrib.appconfig import AppConfig myconf = AppConfig(reload=True) settings = Storage() settings.migrate = myconf.get('db.migrate') settings.title = myconf.get('app.name') settings.subtitle = myconf.get('app.subtitle') settings.author = myconf.get('app.author') settings.author_email = myconf.get('app.email') settings.keywords = myconf.get('app.keywords') settings.description = myconf.get('app.description') settings.layout_theme = 'Default' settings.database_uri = myconf.get('db.uri') settings.security_key = myconf.get('db.security_key') settings.email_server = myconf.get('smtp.server') settings.email_sender = myconf.get('smtp.sender') settings.email_login = '' settings.login_method = 'janrain' settings.janrain_app_name = myconf.get('janrain.app_name') settings.janrain_secret_key = myconf.get('janrain.secret_key') settings.plugins = []