本文整理汇总了Python中pyramid.settings.aslist函数的典型用法代码示例。如果您正苦于以下问题:Python aslist函数的具体用法?Python aslist怎么用?Python aslist使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了aslist函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: configure
def configure(cls, settings):
super(ConfigAccessBackend, cls).configure(settings)
cls._settings = settings
cls.zero_security_mode = asbool(settings.get('auth.zero_security_mode',
False))
cls.admins = aslist(settings.get('auth.admins', []))
cls.user_groups = defaultdict(list)
cls.group_map = {}
if cls.zero_security_mode:
cls.ROOT_ACL = [
(Allow, Everyone, 'login'),
(Allow, Everyone, 'read'),
(Allow, Authenticated, 'write'),
(Allow, 'admin', ALL_PERMISSIONS),
(Deny, Everyone, ALL_PERMISSIONS),
]
else:
cls.ROOT_ACL = IAccessBackend.ROOT_ACL
# Build dict that maps users to list of groups
for key, value in settings.iteritems():
if not key.startswith('group.'):
continue
group_name = key[len('group.'):]
members = aslist(value)
cls.group_map[group_name] = members
for member in members:
cls.user_groups[member].append(group_name)
开发者ID:alonisser,项目名称:pypicloud,代码行数:29,代码来源:__init__.py
示例2: configure
def configure(cls, settings):
kwargs = super(ConfigAccessBackend, cls).configure(settings)
if asbool(settings.get('auth.zero_security_mode', False)):
LOG.warn("Using deprecated option 'auth.zero_security_mode' "
"(replaced by 'pypi.default_read' and "
"'pypi.default_write'")
kwargs['default_read'] = [Everyone]
kwargs['default_write'] = [Authenticated]
kwargs['settings'] = settings
kwargs['admins'] = aslist(settings.get('auth.admins', []))
user_groups = defaultdict(list)
group_map = {}
# Build dict that maps users to list of groups
for key, value in settings.iteritems():
if not key.startswith('group.'):
continue
group_name = key[len('group.'):]
members = aslist(value)
group_map[group_name] = members
for member in members:
user_groups[member].append(group_name)
kwargs['group_map'] = group_map
kwargs['user_groups'] = user_groups
return kwargs
开发者ID:Hexadite,项目名称:pypicloud-hexadite,代码行数:25,代码来源:config.py
示例3: setup_listeners
def setup_listeners(config):
write_actions = (ACTIONS.CREATE, ACTIONS.UPDATE, ACTIONS.DELETE)
settings = config.get_settings()
listeners = aslist(settings['event_listeners'])
for name in listeners:
logger.info('Setting up %r listener')
prefix = 'event_listeners.%s.' % name
try:
listener_mod = config.maybe_dotted(name)
prefix = 'event_listeners.%s.' % name.split('.')[-1]
listener = listener_mod.load_from_config(config, prefix)
except (ImportError, AttributeError):
listener_mod = config.maybe_dotted(settings[prefix + 'use'])
listener = listener_mod.load_from_config(config, prefix)
actions = aslist(settings.get(prefix + 'actions', '')) or write_actions
resource_names = aslist(settings.get(prefix + 'resources', ''))
decorated = _filter_events(listener, actions, resource_names)
if ACTIONS.READ in actions:
config.add_subscriber(decorated, ResourceRead)
if len(actions) == 1:
return
config.add_subscriber(decorated, ResourceChanged)
开发者ID:FooBarQuaxx,项目名称:cliquet,代码行数:27,代码来源:initialization.py
示例4: includeme
def includeme(config):
"""Plug daybed-browserid to daybed"""
settings = config.get_settings()
if 'browserid.audiences' not in settings:
raise ConfigurationError(
'Missing browserid.audiences settings. This is needed for '
'security reasons. See https://developer.mozilla.org/en-US/docs/'
'Persona/Security_Considerations for details.')
if 'browserid.trusted_issuers' not in settings:
raise ConfigurationError(
'Missing browserid.trusted_issuers settings. This is needed for '
'security reasons. See https://developer.mozilla.org/en-US/docs/'
'Persona/Security_Considerations for details.')
verifier_url = settings.get("browserid.verifier_url", None)
audiences = aslist(settings['browserid.audiences'])
trusted_issuers = aslist(settings['browserid.trusted_issuers'])
config.registry['browserid.verifier_url'] = verifier_url
config.registry['browserid.audiences'] = audiences
config.registry['browserid.trusted_issuers'] = trusted_issuers
# Create a backend
backend_class = config.maybe_dotted(
settings.get(
'browserid.backend',
settings['daybed.backend'].replace('daybed', 'daybed_browserid')
)
)
config.registry.browserid_db = backend_class.load_from_config(config)
config.scan("daybed_browserid.views")
开发者ID:spiral-project,项目名称:daybed-browserid,代码行数:32,代码来源:__init__.py
示例5: includeme
def includeme(config):
if hasattr(config.registry, "tonnikala_renderer_factory"):
return
config.registry.tonnikala_renderer_factory = TonnikalaRendererFactory()
config.add_directive("add_tonnikala_extensions", add_tonnikala_extensions)
config.add_directive("add_tonnikala_search_paths", add_tonnikala_search_paths)
config.add_directive("set_tonnikala_reload", set_tonnikala_reload)
settings = config.registry.settings
if "tonnikala.extensions" in settings:
extensions = settings["tonnikala.extensions"]
if not is_nonstr_iter(extensions):
extensions = aslist(extensions, flatten=True)
config.add_tonnikala_extensions(*extensions)
if "tonnikala.search_paths" in settings:
paths = settings["tonnikala.search_paths"]
if not is_nonstr_iter(paths):
paths = aslist(paths, flatten=True)
config.add_tonnikala_search_paths(*paths)
tk_reload = settings.get("tonnikala.reload")
if tk_reload is None:
tk_reload = settings.get("pyramid.reload_templates")
config.set_tonnikala_reload(asbool(tk_reload))
开发者ID:gitter-badger,项目名称:Tonnikala,代码行数:31,代码来源:__init__.py
示例6: depsjs
def depsjs(request):
path_to_source = {}
settings = request.registry.settings
pyramid_closure = settings.get("pyramid_closure")
roots = pyramid_closure.get("roots") if pyramid_closure else \
settings.get("pyramid_closure.roots")
if roots is None:
roots = []
elif isinstance(roots, basestring):
roots = aslist(roots)
for root in roots:
path_to_source.update(depswriter._GetRelativePathToSourceDict(root))
roots_with_prefix = pyramid_closure.get("roots_with_prefix") if \
pyramid_closure else \
settings.get("pyramid_closure.roots_with_prefix")
if roots_with_prefix is None:
roots_with_prefix = []
elif isinstance(roots_with_prefix, basestring):
roots_with_prefix = [aslist(roots_with_prefix)]
for prefix, root in pairwise(roots_with_prefix):
path_to_source.update(
depswriter._GetRelativePathToSourceDict(
root, prefix=request.static_url(prefix)))
request.response.content_type = 'text/javascript'
return depswriter.MakeDepsFile(path_to_source)
开发者ID:pgiraud,项目名称:pyramid_closure,代码行数:34,代码来源:views.py
示例7: includeme
def includeme(config):
settings = config.get_settings()
# Add CORS settings to the base cliquet Service class.
cors_origins = settings["cliquet.cors_origins"]
Service.cors_origins = tuple(aslist(cors_origins))
Service.default_cors_headers = ("Backoff", "Retry-After", "Alert", "Content-Length")
Service.error_handler = lambda self, e: errors.json_error_handler(e)
# Heartbeat registry.
config.registry.heartbeats = {}
# Public settings registry.
config.registry.public_settings = {"cliquet.batch_max_requests"}
# Setup components.
for step in aslist(settings["cliquet.initialization_sequence"]):
step_func = config.maybe_dotted(step)
step_func(config)
# Setup cornice.
config.include("cornice")
# Scan views.
config.scan("cliquet.views")
# Give sign of life.
msg = "%(cliquet.project_name)s %(cliquet.project_version)s starting."
logger.info(msg % settings)
开发者ID:phrawzty,项目名称:cliquet,代码行数:29,代码来源:__init__.py
示例8: factory
def factory(handler, registry):
get = morph.pick(registry.settings, prefix=CONFIG_PREFIX).get
conf = aadict()
conf.enabled = asbool(get('enabled', True))
conf.include = [globre.compile(el, globre.EXACT)
for el in aslist(get('include', []))]
conf.exclude = [globre.compile(el, globre.EXACT)
for el in aslist(get('exclude', []))]
conf.reparse = aslist(get('reparse-methods', DEFAULT_REPARSE_METHODS))
conf.name = get('attribute-name', DEFAULT_ATTRIBUTE_NAME)
conf.deep = asbool(get('combine.deep', True))
conf.reqdict = asbool(get('require-dict', True))
conf.failunk = asbool(get('fail-unknown', True))
conf.ndict = asbool(get('native-dict', False))
conf.error = get('error-handler', None)
if conf.error:
conf.error = asset.symbol(conf.error)
conf.xfmt = asbool(get('xml.enable', True))
conf.jfmt = asbool(get('json.enable', True))
conf.yfmt = asbool(get('yaml.enable', bool(yaml or get('yaml.parser'))))
if conf.jfmt:
conf.jparser = get('json.parser', None)
if conf.jparser:
conf.jparser = asset.symbol(conf.jparser)
if conf.yfmt:
conf.yparser = asset.symbol(get('yaml.parser', 'yaml.load'))
if conf.xfmt:
conf.xparser = asset.symbol(get('xml.parser', 'xml.etree.ElementTree.fromstring'))
def input_tween(request):
return process(handler, request, conf)
return input_tween
开发者ID:canaryhealth,项目名称:pyramid_input,代码行数:31,代码来源:__init__.py
示例9: includeme
def includeme(config):
load_default_settings(config, DEFAULT_SETTINGS)
settings = config.get_settings()
# Add CORS settings to the base cliquet Service class.
cors_origins = settings['cliquet.cors_origins']
Service.cors_origins = tuple(aslist(cors_origins))
Service.default_cors_headers = ('Backoff', 'Retry-After', 'Alert')
# Heartbeat registry.
config.registry.heartbeats = {}
# Setup components.
for step in aslist(settings['cliquet.initialization_sequence']):
step_func = config.maybe_dotted(step)
step_func(config)
# Setup cornice.
config.include("cornice")
# Scan views.
config.scan("cliquet.views")
# Give sign of life.
msg = "%(cliquet.project_name)s %(cliquet.project_version)s starting."
logger.info(msg % settings)
开发者ID:brouberol,项目名称:cliquet,代码行数:26,代码来源:__init__.py
示例10: setup_listeners
def setup_listeners(config):
# Register basic subscriber predicates, to filter events.
config.add_subscriber_predicate('for_actions', EventActionFilter)
config.add_subscriber_predicate('for_resources', EventResourceFilter)
write_actions = (ACTIONS.CREATE, ACTIONS.UPDATE, ACTIONS.DELETE)
settings = config.get_settings()
project_name = settings.get('project_name', '')
listeners = aslist(settings['event_listeners'])
for name in listeners:
logger.info('Setting up %r listener' % name)
prefix = 'event_listeners.%s.' % name
try:
listener_mod = config.maybe_dotted(name)
prefix = 'event_listeners.%s.' % name.split('.')[-1]
listener = listener_mod.load_from_config(config, prefix)
except (ImportError, AttributeError):
module_setting = prefix + "use"
# Read from ENV or settings.
module_value = utils.read_env(project_name + "." + module_setting,
settings.get(module_setting))
listener_mod = config.maybe_dotted(module_value)
listener = listener_mod.load_from_config(config, prefix)
# If StatsD is enabled, monitor execution time of listeners.
if getattr(config.registry, "statsd", None):
statsd_client = config.registry.statsd
key = 'listeners.%s' % name
listener = statsd_client.timer(key)(listener.__call__)
# Optional filter by event action.
actions_setting = prefix + "actions"
# Read from ENV or settings.
actions_value = utils.read_env(project_name + "." + actions_setting,
settings.get(actions_setting, ""))
actions = aslist(actions_value)
if len(actions) > 0:
actions = ACTIONS.from_string_list(actions)
else:
actions = write_actions
# Optional filter by event resource name.
resource_setting = prefix + "resources"
# Read from ENV or settings.
resource_value = utils.read_env(project_name + "." + resource_setting,
settings.get(resource_setting, ""))
resource_names = aslist(resource_value)
# Pyramid event predicates.
options = dict(for_actions=actions, for_resources=resource_names)
if ACTIONS.READ in actions:
config.add_subscriber(listener, ResourceRead, **options)
if len(actions) == 1:
return
config.add_subscriber(listener, ResourceChanged, **options)
开发者ID:DarkDare,项目名称:kinto,代码行数:59,代码来源:initialization.py
示例11: _parse_settings
def _parse_settings(settings):
rawes_args = {}
defaults = {
'url': 'http://localhost:9200',
'timeout': 30,
'path': '',
'json_encoder': encode_date_optional_time,
}
rawes_args = defaults.copy()
# set string settings
for short_key_name in ('path',):
key_name = 'rawes.%s' % (short_key_name,)
if key_name in settings:
rawes_args[short_key_name] = \
settings.get(key_name, defaults.get(short_key_name))
# set list settings
for short_key_name in ('url',):
key_name = 'rawes.%s' % (short_key_name,)
if key_name in settings:
rawes_args[short_key_name] = \
(aslist(settings.get(key_name, defaults.get(short_key_name)))
if len(aslist(settings.get(key_name, defaults.get(short_key_name)))) > 1
else settings.get(key_name, defaults.get(short_key_name)).strip())
# integer settings
for short_key_name in ('timeout',):
key_name = 'rawes.%s' % (short_key_name,)
if key_name in settings:
rawes_args[short_key_name] = \
int(settings.get(key_name, defaults.get(short_key_name)))
# function settings
for short_key_name in ('json_encoder',):
key_name = 'rawes.%s' % (short_key_name,)
r = DottedNameResolver()
if key_name in settings:
rawes_args[short_key_name] = \
r.resolve(settings.get(key_name))
for short_key_name in ('json_decoder',):
key_name = 'rawes.%s' % (short_key_name,)
r = DottedNameResolver()
if key_name in settings:
rawes_args[short_key_name] = \
r.resolve(settings.get(key_name))().decode
# removed settings
for short_key_name in ('connection_type', 'except_on_error'):
key_name = 'rawes.%s' % (short_key_name,)
if key_name in settings:
warnings.warn(
'%s is no longer supported, please remove from your settings.',
UserWarning
)
return rawes_args
开发者ID:claeyswo,项目名称:pyramid_rawes,代码行数:59,代码来源:__init__.py
示例12: configure
def configure(cls, settings):
""" Configure the access backend with app settings """
return {
'default_read': aslist(settings.get('pypi.default_read',
['authenticated'])),
'default_write': aslist(settings.get('pypi.default_write', [])),
'cache_update': aslist(settings.get('pypi.cache_update',
['authenticated'])),
}
开发者ID:Hexadite,项目名称:pypicloud-hexadite,代码行数:9,代码来源:base.py
示例13: parse_options_from_settings
def parse_options_from_settings(settings, settings_prefix, maybe_dotted):
""" Parse options for use with Mako's TemplateLookup from settings."""
def sget(name, default=None):
return settings.get(settings_prefix + name, default)
reload_templates = sget('reload_templates', None)
if reload_templates is None:
reload_templates = settings.get('pyramid.reload_templates', None)
reload_templates = asbool(reload_templates)
directories = sget('directories', [])
module_directory = sget('module_directory', None)
input_encoding = sget('input_encoding', 'utf-8')
error_handler = sget('error_handler', None)
default_filters = sget('default_filters', 'h')
imports = sget('imports', None)
future_imports = sget('future_imports', None)
strict_undefined = asbool(sget('strict_undefined', False))
preprocessor = sget('preprocessor', None)
if not is_nonstr_iter(directories):
# Since we parse a value that comes from an .ini config,
# we treat whitespaces and newline characters equally as list item separators.
directories = aslist(directories, flatten=True)
directories = [abspath_from_asset_spec(d) for d in directories]
if module_directory is not None:
module_directory = abspath_from_asset_spec(module_directory)
if error_handler is not None:
error_handler = maybe_dotted(error_handler)
if default_filters is not None:
if not is_nonstr_iter(default_filters):
default_filters = aslist(default_filters)
if imports is not None:
if not is_nonstr_iter(imports):
imports = aslist(imports, flatten=False)
if future_imports is not None:
if not is_nonstr_iter(future_imports):
future_imports = aslist(future_imports)
if preprocessor is not None:
preprocessor = maybe_dotted(preprocessor)
return dict(
directories=directories,
module_directory=module_directory,
input_encoding=input_encoding,
error_handler=error_handler,
default_filters=default_filters,
imports=imports,
future_imports=future_imports,
filesystem_checks=reload_templates,
strict_undefined=strict_undefined,
preprocessor=preprocessor,
)
开发者ID:Rafails,项目名称:MyCalc,代码行数:57,代码来源:__init__.py
示例14: includeme
def includeme(config):
""" This function returns a Pyramid WSGI application."""
def contextual_route(name, route, from_root=True):
config.add_route('contextual_'+name, '/{discussion_slug}'+route)
if from_root:
config.add_route(name, route)
contextual_route('login', '/login')
contextual_route('login_forceproviders', '/login_showallproviders')
contextual_route('logout', '/logout')
# type in u(sername), id, email, {velruse-id-type}
config.add_route('profile_user', '/user/{type}/{identifier}')
config.add_route('avatar', '/user/{type}/{identifier}/avatar/{size:\d+}')
contextual_route('register', '/register')
contextual_route('user_confirm_email', '/users/email_confirm/{ticket}')
# Do we want this?
# config.add_route('profile_search', '/usernames/{user_name}')
# TODO: secure next three methods to avoid spamming the user.
contextual_route('confirm_emailid_sent',
'/confirm_email_sent_id/{email_account_id:\d+}')
contextual_route('confirm_email_sent', '/confirm_email_sent/{email}')
contextual_route('password_change_sent',
'/password_change_sent/{profile_id:\d+}')
contextual_route('request_password_change', '/req_password_change')
contextual_route('do_password_change', '/do_password_change/{ticket}')
contextual_route('welcome', '/welcome/{ticket}')
contextual_route('finish_password_change', '/finish_password_change')
config.add_route('contextual_social_auth', '/{discussion_slug}/login/{backend}')
contextual_route('add_social_account', '/add_account/{backend}')
# determine which providers we want to configure
settings = config.get_settings()
providers = aslist(settings['login_providers'])
config.add_settings(login_providers=providers)
config.add_settings(trusted_login_providers=aslist(
settings.get('trusted_login_providers', '')))
if not any(providers):
sys.stderr.write('no login providers configured, double check '
'your ini file and add a few')
settings = config.registry.settings
for name in ('SOCIAL_AUTH_AUTHENTICATION_BACKENDS',
'SOCIAL_AUTH_USER_FIELDS',
'SOCIAL_AUTH_PROTECTED_USER_FIELDS',
'SOCIAL_AUTH_FIELDS_STORED_IN_SESSION'):
settings[name] = aslist(settings.get(name, ''))
for k in settings.iterkeys():
if k.endswith("_SCOPE") and k.startswith("SOCIAL_AUTH_"):
settings[k] = aslist(settings.get(k, ''))
config.add_request_method(
'assembl.auth.social_auth.get_user', 'user', reify=True)
config.include('social.apps.pyramid_app')
config.scan()
config.scan('social.apps.pyramid_app')
开发者ID:festrade,项目名称:assembl,代码行数:55,代码来源:__init__.py
示例15: load_from_config
def load_from_config(config, prefix=''):
settings = config.get_settings()
collections = aslist(settings.get(prefix + 'collections', ''))
changes_bucket = settings.get(prefix + 'bucket', 'monitor')
changes_collection = settings.get(prefix + 'collection', 'changes')
changes_principals = aslist(settings.get(prefix + 'principals', Everyone))
return Listener(collections, changes_bucket, changes_collection,
changes_principals)
开发者ID:Sayli-Karnik,项目名称:kinto-changes,代码行数:11,代码来源:listener.py
示例16: factory
def factory(handler, registry):
get = registry.settings.get
on = [e.upper() for e in aslist(get('methodrewrite.on', 'GET POST'))]
to = [e.upper() for e in aslist(get('methodrewrite.to', ' '.join(HTTP_METHODS)))]
name = get('methodrewrite.param', '_method')
def methodrewrite_tween(request):
if request.method.upper() in on and name in request.params:
meth = request.params.get(name, '').upper()
if meth and ( not to or meth in to ):
request.method = meth
return handler(request)
return methodrewrite_tween
开发者ID:mattjeffery,项目名称:pyramid_methodrewrite,代码行数:12,代码来源:__init__.py
示例17: crate_init
def crate_init(config):
settings = config.get_settings()
engine = create_engine(
'crate://',
connect_args={
'servers': aslist(settings['crate.hosts'])
},
echo=asbool(settings.get('crate.echo', 'False')),
pool_size=int(settings.get('sql.pool_size', 5)),
max_overflow=int(settings.get('sql.max_overflow', 5))
)
DB_SESSION.configure(bind=engine)
Base.metadata.bind = engine
CRATE_CONNECTION.configure(aslist(settings['crate.hosts']))
开发者ID:lumannnn,项目名称:vyi,代码行数:14,代码来源:server.py
示例18: configure
def configure(cls, settings):
""" Configure the access backend with app settings """
rounds = int(settings.get("auth.rounds", DEFAULT_ROUNDS))
return {
"default_read": aslist(
settings.get("pypi.default_read", ["authenticated"])
),
"default_write": aslist(settings.get("pypi.default_write", [])),
"cache_update": aslist(
settings.get("pypi.cache_update", ["authenticated"])
),
"pwd_context": get_pwd_context(rounds),
"token_expiration": int(settings.get("auth.token_expire", ONE_WEEK)),
"signing_key": settings.get("auth.signing_key"),
}
开发者ID:mathcamp,项目名称:pypicloud,代码行数:15,代码来源:base.py
示例19: main
def main(argv=sys.argv):
# late import so we can run on a non-raspi device
from RPi import GPIO
if len(argv) != 2:
usage(argv)
config_uri = argv[1]
setup_logging(config_uri)
settings = get_appsettings(config_uri)
GPIO.setmode(GPIO.BCM)
for pin in map(int, aslist(settings["brewcontrol.inpins"])):
GPIO.setup(pin, GPIO.IN)
for pin in map(int, aslist(settings["brewcontrol.outpins"])):
GPIO.setup(pin, GPIO.OUT)
开发者ID:pombredanne,项目名称:brewcontrol,代码行数:15,代码来源:setup_pins.py
示例20: includeme
def includeme(config):
"""
Configures the Celery connection from the pyramid side of the application.
Pyramid must know how to talk to the celery process in order to send
asynchronous jobs.
This method will not actually start the celery process.
:param config: Pyramid configuration object
"""
settings = config.registry.settings
assert 'celery.blame' in settings, 'Must specify an blame user'
app.conf.update(
BROKER_URL=settings['celery.broker.url'],
CELERY_RESULT_BACKEND=settings['celery.backend.url'],
BROKER_TRANSPORT_OPTIONS={
'fanout_prefix': True,
'fanout_patterns': True
},
CELERY_INCLUDE=aslist(settings.get('celery.include', [])),
CELERYBEAT_SCHEDULE=_get_schedule(settings)
)
app.settings = settings
开发者ID:davidmote,项目名称:occams,代码行数:28,代码来源:celery.py
注:本文中的pyramid.settings.aslist函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论