def connect(self): # Syntax: "dbtype://*****:*****@host:port/dbname" # The /dbname syntax doesn't seem to work with SQLite... from gluon.tools import DAL if self.server == self.port == self.db_name == None: self.server = 'sqlite://oauth.sqlite' conn = self.server if not self.port else self.server + self.port self.db = DAL(conn, pool_size=1, check_reserved=['all'])
settings.email_admin = '*****@*****.**' settings.home_dir = '/home/CBSData/' # settings.home_dir = '/home/developers/manhtd/CBSData/' settings.cp_dir = 'CPData/' settings.creator_dir = 'CreatorImages/' settings.product_image_dir = 'ProductImages/' settings.rpc_server = "http://127.0.0.1" settings.discount_value = 30 response.generic_patterns = ['*'] from gluon.custom_import import track_changes track_changes(True) db = DAL(settings.database_uri, pool_size=1, check_reserved=['all'], migrate_enabled=False, decode_credentials=True) ## configure email mail = Mail() mail.settings.server = settings.email_server mail.settings.sender = settings.email_sender mail.settings.login = settings.email_login ## configure auth policy url_index = URL('default', 'index') auth = Auth(db, hmac_key=settings.security_key, controller='users', function='index') ######################################### db.define_table('clsb_country', Field('country_name', type = 'string', notnull = True, default = "Viet Nam", label = T('Country name')),
# -*- 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 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') ## store sessions and tickets there