當前位置: 首頁>>代碼示例>>Python>>正文


Python settings.get方法代碼示例

本文整理匯總了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 
開發者ID:opendevops-cn,項目名稱:codo-tools,代碼行數:13,代碼來源:db_context.py

示例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='緩存成功')) 
開發者ID:opendevops-cn,項目名稱:codo-admin,代碼行數:17,代碼來源:verify_handler.py

示例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) 
開發者ID:opendevops-cn,項目名稱:codo-task,代碼行數:13,代碼來源:db_context.py

示例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) 
開發者ID:vgrem,項目名稱:Office365-REST-Python-Client,代碼行數:8,代碼來源:outlook_case.py

示例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) 
開發者ID:vgrem,項目名稱:Office365-REST-Python-Client,代碼行數:9,代碼來源:test_sharepoint_client.py

示例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) 
開發者ID:opendevops-cn,項目名稱:codo-cron,代碼行數:14,代碼來源:db_context.py


注:本文中的settings.settings.get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。