本文整理汇总了Python中repoze.who.utils.resolveDotted函数的典型用法代码示例。如果您正苦于以下问题:Python resolveDotted函数的具体用法?Python resolveDotted怎么用?Python resolveDotted使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了resolveDotted函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _base_plugin_maker
def _base_plugin_maker(user_class=None, dbsession=None):
"""
Turn ``userclass`` and ``dbsession`` into Python objects.
"""
if user_class is None:
raise ValueError('user_class must not be None')
if dbsession is None:
raise ValueError('dbsession must not be None')
return resolveDotted(user_class), resolveDotted(dbsession)
示例2: make_identification_plugin
def make_identification_plugin(
fb_connect_field="fb_connect",
db_session=None,
user_class=None,
fb_user_class=None,
session_name=None,
login_handler_path=None,
logout_handler_paths=None,
login_form_url=None,
error_field='error',
logged_in_url=None,
logged_out_url=None,
came_from_field='came_from',
rememberer_name=None,
md_provider_name='facebook_connect_md',
fields='',
):
if login_form_url is None:
raise ValueError("login_form_url needs to be given")
if rememberer_name is None:
raise ValueError("rememberer_name needs to be given")
if login_handler_path is None:
raise ValueError("login_handler_path needs to be given")
if logout_handler_paths is None:
raise ValueError("logout_handler_paths needs to be given")
if session_name is None:
raise ValueError("session_name needs to be given")
if logged_in_url is None:
raise ValueError("logged_in_url needs to be given")
if logged_out_url is None:
raise ValueError("logged_out_url needs to be given")
fields = [attr.strip(',') for attr in fields.split()] or None
plugin = FacebookConnectIdentificationPlugin(
fb_connect_field=fb_connect_field,
error_field=error_field,
db_session=resolveDotted(db_session),
user_class=resolveDotted(user_class),
fb_user_class=resolveDotted(fb_user_class),
session_name=session_name,
login_form_url=login_form_url,
login_handler_path=login_handler_path,
logout_handler_paths=logout_handler_paths,
logged_in_url=logged_in_url,
logged_out_url=logged_out_url,
came_from_field=came_from_field,
rememberer_name=rememberer_name,
md_provider_name=md_provider_name,
fields=fields,
)
return plugin
示例3: make_authenticator_plugin
def make_authenticator_plugin(query=None, conn_factory=None,
compare_fn=None, **kw):
from repoze.who.utils import resolveDotted
if query is None:
raise ValueError('query must be specified')
if conn_factory is None:
raise ValueError('conn_factory must be specified')
try:
conn_factory = resolveDotted(conn_factory)(**kw)
except Exception as why:
raise ValueError('conn_factory could not be resolved: %s' % why)
if compare_fn is not None:
compare_fn = resolveDotted(compare_fn)
return SQLAuthenticatorPlugin(query, conn_factory, compare_fn)
示例4: make_smtp_authenticator
def make_smtp_authenticator(dbsession, asm, dommodel, dam):
"return smtp authenticator"
for param in [('dbsession', dbsession),
('asm', asm),
('dommodel', dommodel),
('dam', dam)]:
check_param(param[0], param[1])
session = resolveDotted(dbsession)
authmodel = resolveDotted(asm)
dmodel = resolveDotted(dommodel)
damodel = resolveDotted(dam)
authenticator = BaruwaSMTPAuthPlugin(session, authmodel, dmodel, damodel)
return authenticator
示例5: make_plugin
def make_plugin(secret=None,
secretfile=None,
cookie_name='auth_tkt',
secure=False,
include_ip=False,
timeout=None,
reissue_time=None,
userid_checker=None,
):
from repoze.who.utils import resolveDotted
if (secret is None and secretfile is None):
raise ValueError("One of 'secret' or 'secretfile' must not be None.")
if (secret is not None and secretfile is not None):
raise ValueError("Specify only one of 'secret' or 'secretfile'.")
if secretfile:
secretfile = os.path.abspath(os.path.expanduser(secretfile))
if not os.path.exists(secretfile):
raise ValueError("No such 'secretfile': %s" % secretfile)
with open(secretfile) as f:
secret = f.read().strip()
if timeout:
timeout = int(timeout)
if reissue_time:
reissue_time = int(reissue_time)
if userid_checker is not None:
userid_checker = resolveDotted(userid_checker)
plugin = AuthTktCookiePlugin(secret,
cookie_name,
_bool(secure),
_bool(include_ip),
timeout,
reissue_time,
userid_checker,
)
return plugin
示例6: _load_function_from_kwds
def _load_function_from_kwds(name, kwds):
"""Load a plugin argument as a function created from the given kwds.
This function is a helper to load and possibly curry a callable argument
to the plugin. It grabs the value from the dotted python name found in
kwds[name] and checks that it is a callable. It looks for arguments of
the form kwds[name_*] and curries them into the function as additional
keyword argument before returning.
"""
# See if we actually have the named object.
dotted_name = kwds.pop(name, None)
if dotted_name is None:
return None
func = resolveDotted(dotted_name)
# Check that it's a callable.
if not callable(func):
raise ValueError("Argument %r must be callable" % (name,))
# Curry in any keyword arguments.
func_kwds = {}
prefix = name + "_"
for key in kwds.keys():
if key.startswith(prefix):
func_kwds[key[len(prefix):]] = kwds.pop(key)
# Return the original function if not currying anything.
# This is both more effient and better for unit testing.
if func_kwds:
func = functools.partial(func, **func_kwds)
return func
示例7: _load_object_from_kwds
def _load_object_from_kwds(name, kwds):
"""Load a plugin argument as an object created from the given kwds.
This function is a helper to load and possibly instanciate an argument
to the plugin. It grabs the value from the dotted python name found in
kwds[name]. If this is a callable, it looks for arguments of the form
kwds[name_*] and calls it with them to instanciate an object.
"""
# See if we actually have the named object.
dotted_name = kwds.pop(name, None)
if dotted_name is None:
return None
obj = resolveDotted(dotted_name)
# Extract any arguments for the callable.
obj_kwds = {}
prefix = name + "_"
for key in kwds.keys():
if key.startswith(prefix):
obj_kwds[key[len(prefix):]] = kwds.pop(key)
# Call it if callable.
if callable(obj):
obj = obj(**obj_kwds)
elif obj_kwds:
raise ValueError("arguments provided for non-callable %r" % (name,))
return obj
示例8: make_metadata_plugin
def make_metadata_plugin(name=None, query=None, conn_factory=None,
filter=None, **kw):
from repoze.who.utils import resolveDotted
if name is None:
raise ValueError('name must be specified')
if query is None:
raise ValueError('query must be specified')
if conn_factory is None:
raise ValueError('conn_factory must be specified')
try:
conn_factory = resolveDotted(conn_factory)(**kw)
except Exception as why:
raise ValueError('conn_factory could not be resolved: %s' % why)
if filter is not None:
filter = resolveDotted(filter)
return SQLMetadataProviderPlugin(name, query, conn_factory, filter)
示例9: make_smtp_authenticator
def make_smtp_authenticator(dbsession, authsettingsmodel, domainmodel,
domainaliasmodel):
"return smtp authenticator"
for param in [('dbsession', dbsession),
('authsettingsmodel', authsettingsmodel),
('domainmodel', domainmodel),
('domainaliasmodel', domainaliasmodel)]:
check_param(param[0], param[1])
session = resolveDotted(dbsession)
authmodel = resolveDotted(authsettingsmodel)
dmodel = resolveDotted(domainmodel)
damodel = resolveDotted(domainaliasmodel)
authenticator = BaruwaSMTPAuthPlugin(session, authmodel, dmodel, damodel)
return authenticator
示例10: make_plugin
def make_plugin(filename=None, check_fn=None):
if filename is None:
raise ValueError('filename must be specified')
if check_fn is None:
raise ValueError('check_fn must be specified')
check = resolveDotted(check_fn)
return HTPasswdPlugin(filename, check)
示例11: _load_from_callable
def _load_from_callable(name, kwds, converters={}):
"""Load a plugin argument from dotted python name of callable.
This function is a helper to load and possibly instanciate an argument
to the plugin. It grabs the value from the dotted python name found in
kwds[name]. If this is a callable, it it looks for arguments of the form
kwds[name_*] and calls the object with them.
"""
# See if we actually have the named object.
dotted_name = kwds.pop(name, None)
if dotted_name is None:
return None
obj = resolveDotted(dotted_name)
# Extract any arguments for the callable.
obj_kwds = {}
prefix = name + "_"
for key in kwds.keys():
if key.startswith(prefix):
obj_kwds[key[len(prefix):]] = kwds.pop(key)
# To any type conversion on the arguments.
for key, value in obj_kwds.iteritems():
converter = converters.get(key)
if converter is not None:
obj_kwds[key] = converter(value)
# Call it if callable.
if callable(obj):
obj = obj(**obj_kwds)
elif obj_kwds:
raise ValueError("arguments provided for non-callable %r" % (name,))
return obj
示例12: resolveRegistrationForm
def resolveRegistrationForm():
custom_schema = request.environ["fi.infigo.account"].config["registration"].get("schema", None)
if custom_schema:
from repoze.who.utils import resolveDotted
klass = resolveDotted(custom_schema)
return klass()
return RegistrationForm()
示例13: from_settings
def from_settings(cls, settings, prefix="who."):
"""Create a new WhoAuthenticationPolicy from app settings dict."""
api_factory = api_factory_from_settings(settings, prefix)
callback = settings.get(prefix + "callback")
if callback is not None:
callback = resolveDotted(callback)
if callback is not None:
assert callable(callback)
return cls(api_factory, callback)
示例14: _base_plugin_maker
def _base_plugin_maker(user_class=None):
"""
Turn ``userclass`` into Python object.
"""
if user_class is None:
raise ValueError('user_class must not be None')
return resolveDotted(user_class)
示例15: make_rad_authenticator
def make_rad_authenticator(dbsession, rsm, asm, dommodel, dam):
"return radius authenticator"
for param in [('dbsession', dbsession),
('rsm', rsm),
('asm', asm),
('dommodel', dommodel),
('dam', dam)]:
check_param(param[0], param[1])
session = resolveDotted(dbsession)
radmodel = resolveDotted(rsm)
authmodel = resolveDotted(asm)
dmodel = resolveDotted(dommodel)
damodel = resolveDotted(dam)
authenticator = BaruwaRadiusAuthPlugin(session, radmodel,
authmodel, dmodel,
damodel)
return authenticator