本文整理汇总了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)