当前位置: 首页>>代码示例>>Python>>正文


Python Config.from_object方法代码示例

本文整理汇总了Python中flask.config.Config.from_object方法的典型用法代码示例。如果您正苦于以下问题:Python Config.from_object方法的具体用法?Python Config.from_object怎么用?Python Config.from_object使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flask.config.Config的用法示例。


在下文中一共展示了Config.from_object方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: app_config

# 需要导入模块: from flask.config import Config [as 别名]
# 或者: from flask.config.Config import from_object [as 别名]
def app_config(postgres_user_conf):
    from flask.config import Config
    from datacat.settings import testing

    conf = Config('')
    conf.from_object(testing)
    conf['DATABASE'] = postgres_user_conf
    return conf
开发者ID:rshk-archive,项目名称:datacat-poc-140825,代码行数:10,代码来源:conftest.py

示例2: load_config

# 需要导入模块: from flask.config import Config [as 别名]
# 或者: from flask.config.Config import from_object [as 别名]
def load_config():
    cfg = Config(dirname(dirname(__file__)))
    cfg.from_object("autobit.settings")
    if "AUTOBIT_SETTINGS" in os.environ:
        cfg.from_envvar("AUTOBIT_SETTINGS")

    if not exists(cfg['WATCH_DIR']):
        logger.info("Creating watch dir: {}".format(cfg['WATCH_DIR']))
        os.makedirs(cfg['WATCH_DIR'])

    return cfg
开发者ID:leighmacdonald,项目名称:autobit,代码行数:13,代码来源:__init__.py

示例3: make_config

# 需要导入模块: from flask.config import Config [as 别名]
# 或者: from flask.config.Config import from_object [as 别名]
def make_config(app=None):
    if app is not None:
        cfg = app.config
    else:
        from flask.config import Config
        root_path = os.path.dirname(__file__).rsplit('/', 1)[0]
        cfg = Config(root_path)

    # customize config here
    cfg.from_object(default_config)
    cfg.from_pyfile('myapp.cfg', silent=True)
    cfg.from_envvar('MYAPP_CONFIG', silent=True)
    cfg['BABEL_DEFAULT_LOCALE'] = cfg['LANG']
    return cfg
开发者ID:haje01,项目名称:flask-plate,代码行数:16,代码来源:make_config.py

示例4: ImmutableDict

# 需要导入模块: from flask.config import Config [as 别名]
# 或者: from flask.config.Config import from_object [as 别名]
class CartesiusSuite :
	#: Default configuration parameters.
	default_config = ImmutableDict({
		'DEBUG':                                False,
		'SERVER_NAME':                          None,
		'APPLICATION_ROOT':                     None
	})

	def __init__(self, configuration = None) :
		self.make_config(configuration)
		self.make_servers()

	def make_config(self, configuration):
		self.config = Config(None, self.default_config)
		
		if (configuration) :
			self.config.from_object(configuration)

	def make_servers(self) :
		self.servers = {}
		for server in self.config['SERVERS'] :
			server_path = self.config['SERVER_PATH'] + "." + server['path'] + "."
			if( 'app_name' in server ) :
				server_path += server['app_name']
			else :
				server_path += 'app'
			self.servers[server['name']] = CartesiusServer(server_path)

	def start(self, server) :
		self.servers[server].start()

	def start_all(self) :
		for server in self.servers :
			self.servers[server].start()

	def stop(self, server) :
		self.servers[server].stop()

	def stop_all(self) :
		for server in self.servers :
			server.stop()
开发者ID:chebizarro,项目名称:cartesius-suite,代码行数:43,代码来源:app.py

示例5: make_config

# 需要导入模块: from flask.config import Config [as 别名]
# 或者: from flask.config.Config import from_object [as 别名]
def make_config():
    cfg = Config('')
    cfg.from_object('datacat.settings.default')
    cfg.from_envvar('DATACAT_SETTINGS', silent=True)
    return cfg
开发者ID:rshk-archive,项目名称:datacat-poc-140825,代码行数:7,代码来源:core.py

示例6: Config

# 需要导入模块: from flask.config import Config [as 别名]
# 或者: from flask.config.Config import from_object [as 别名]
from __future__ import unicode_literals

import os

from flask import Flask
from flask.config import Config
from flaskext.csrf import csrf

# config

config = Config(None, Flask.default_config)
config.from_object('rentmybike.settings.default')
if os.getenv('RENTMYBIKE_ENV'):
    config.from_object('rentmybike.settings.' + os.getenv('RENTMYBIKE_ENV'))
else:
    config.from_object('rentmybike.settings.custom')

# app

from application import RentMyBike  # deferred

app = RentMyBike()
if app.config['DUMMY_DATA']:
    app.add_dummy_data()
csrf(app)

# controllers

import controllers  # deferred
开发者ID:juanfiguera,项目名称:rentmybikes,代码行数:31,代码来源:__init__.py

示例7: Config

# 需要导入模块: from flask.config import Config [as 别名]
# 或者: from flask.config.Config import from_object [as 别名]
from flask.config import Config
from celery.utils.log import get_task_logger
from ckanpackager.tasks.url_package_task import UrlPackageTask
from ckanpackager.tasks.datastore_package_task import DatastorePackageTask
from ckanpackager.tasks.dwc_archive_package_task import DwcArchivePackageTask

config = Config(__file__)
config.from_object('ckanpackager.config_defaults')
config.from_envvar('CKANPACKAGER_CONFIG')

from celery import Celery

app = Celery('tasks', broker=config['CELERY_BROKER'])
app.conf.CELERY_DISABLE_RATE_LIMITS = True
app.conf.CELERY_ACCEPT_CONTENT = ['json']
app.conf.CELERY_TASK_SERIALIZER = 'json'
app.conf.CELERY_CREATE_MISSING_QUEUES = True
app.conf.CELERY_DEFAULT_QUEUE = 'slow'


@app.task
def run_task(task, request):
    """ Run/enqueue the given task for the given request
   
    Note that the request should be validated before
    this is called.
 
    @param task: Name of the task. One of package_url,
                 package_dwc_archive or package_datastore
    @param request: Dictionary containing the request
    """
开发者ID:NaturalHistoryMuseum,项目名称:ckanpackager,代码行数:33,代码来源:task_setup.py


注:本文中的flask.config.Config.from_object方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。