本文整理匯總了Python中settings.settings.get方法的典型用法代碼示例。如果您正苦於以下問題:Python settings.get方法的具體用法?Python settings.get怎麽用?Python settings.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類settings.settings
的用法示例。
在下文中一共展示了settings.get方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_db_engine
# 需要導入模塊: from settings import settings [as 別名]
# 或者: from settings.settings import get [as 別名]
def get_db_engine(db_key):
databases = settings.get('databases', 0)
db_conf = databases[db_key]
dbuser = db_conf['user']
dbpwd = db_conf['pwd']
dbhost = db_conf['host']
dbport = db_conf.get('port', 0)
dbname = db_conf['name']
return create_engine('mysql+pymysql://{user}:{pwd}@{host}:{port}/{dbname}?charset=utf8'
.format(user=dbuser, pwd=quote_plus(dbpwd), host=dbhost, port=dbport, dbname=dbname),
logging_name=db_key, pool_pre_ping=True) #pool_size=10 poolclass=NullPool, pool_recycle=60
示例2: post
# 需要導入模塊: from settings import settings [as 別名]
# 或者: from settings.settings import get [as 別名]
def post(self, *args, **kwargs):
data = json.loads(self.request.body.decode("utf-8"))
user_id = data.get('user_id', None)
secret_key = data.get('secret_key', None)
is_superuser = data.get('is_superuser', False)
if secret_key != my_settings.get('secret_key'):
return self.write(dict(code=-1, msg='secret key error'))
if not user_id:
return self.write(dict(code=-2, msg='auth failed'))
else:
my_verify = MyVerify(str(user_id), is_superuser)
my_verify.write_verify()
return self.write(dict(code=0, msg='緩存成功'))
示例3: get_db_engine
# 需要導入模塊: from settings import settings [as 別名]
# 或者: from settings.settings import get [as 別名]
def get_db_engine(db_key):
databases = settings.get('databases', 0)
db_conf = databases[db_key]
dbuser = db_conf['user']
dbpwd = db_conf['pwd']
dbhost = db_conf['host']
dbport = db_conf.get('port', 0)
dbname = db_conf['name']
return create_engine('mysql+pymysql://{user}:{pwd}@{host}:{port}/{dbname}?charset=utf8'
.format(user=dbuser, pwd=quote_plus(dbpwd), host=dbhost, port=dbport, dbname=dbname),
logging_name=db_key, pool_size=10)
示例4: setUpClass
# 需要導入模塊: from settings import settings [as 別名]
# 或者: from settings.settings import get [as 別名]
def setUpClass(cls):
client_id = settings.get('client_credentials').get('client_id')
username = settings.get('user_credentials').get('username')
password = settings.get('user_credentials').get('password')
cls.client = OutlookClient.from_tenant(settings.get('tenant'))\
.with_user_credentials(client_id, username, password)
示例5: test1_connect_with_app_principal
# 需要導入模塊: from settings import settings [as 別名]
# 或者: from settings.settings import get [as 別名]
def test1_connect_with_app_principal(self):
credentials = ClientCredential(settings.get('client_credentials').get('client_id'),
settings.get('client_credentials').get('client_secret'))
ctx = ClientContext.connect_with_credentials(settings['url'], credentials)
self.assertIsInstance(ctx.authentication_context.provider, ACSTokenProvider)
self.assertIsInstance(ctx.authentication_context.provider.token, TokenResponse)
self.assertTrue(ctx.authentication_context.provider.token.is_valid)
示例6: get_db_url
# 需要導入模塊: from settings import settings [as 別名]
# 或者: from settings.settings import get [as 別名]
def get_db_url(dbkey):
databases = settings.get('databases', 0)
db_conf = databases[dbkey]
dbuser = db_conf['user']
dbpwd = db_conf['pwd']
dbhost = db_conf['host']
dbport = db_conf.get('port', 3306)
dbname = db_conf['name']
return 'mysql+pymysql://{user}:{pwd}@{host}:{port}/{dbname}?charset=utf8'.format(user=dbuser, pwd=quote_plus(dbpwd),
host=dbhost, port=dbport,
dbname=dbname, poolclass=NullPool)