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


Python OrderedDict.get方法代码示例

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


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

示例1: AuthProvider

# 需要导入模块: from synnefo.lib.ordereddict import OrderedDict [as 别名]
# 或者: from synnefo.lib.ordereddict.OrderedDict import get [as 别名]
class AuthProvider(object):

    __metaclass__ = AuthProviderBase

    module = None
    module_enabled = False
    is_primary = False

    message_tpls = OrderedDict((
        ('title', '{module_title}'),
        ('login_title', '{title} LOGIN'),
        ('method_prompt', '{title} login'),
        ('account_prompt', '{title} account'),
        ('signup_title', '{title}'),
        ('profile_title', '{title}'),
        ('method_details', '{account_prompt}: {identifier}'),
        ('primary_login_prompt', 'Login using {account_prompt}'),
        ('required', '{title} is required. You can assign it '
                     'from your profile page'),
        ('login_prompt', ''),
        ('add_prompt', 'Allows you to login using {title}'),
        ('login_extra', ''),
        ('username', '{username}'),
        ('disabled_for_create', 'It seems this is the first time you\'re '
                                'trying to access {service_name}. '
                                'Unfortunately, we are not accepting new '
                                'users at this point.'),
        ('switch_success', 'Account changed successfully.'),
        ('cannot_login', '{title} is not available for login. '
                         'Please use one of your other available methods '
                         'to login ({available_methods_links}'),

        # icons should end with _icon
        ('module_medium_icon', 'im/auth/icons-medium/{module}.png'),
        ('module_icon', 'im/auth/icons/{module}.png'))
    )

    messages = {}
    module_urls = {}

    remote_authenticate = True
    remote_logout_url = None

    # templates
    primary_login_template = 'im/auth/generic_primary_login.html'
    login_template = 'im/auth/generic_login.html'
    signup_template = 'im/signup.html'
    login_prompt_template = 'im/auth/generic_login_prompt.html'
    signup_prompt_template = 'im/auth/signup_prompt.html'

    default_policies = {
        'login': True,
        'create': True,
        'add': True,
        'remove': True,
        'limit': 1,
        'switch': True,
        'add_groups': [],
        'creation_groups': [],
        'mirror_groups': False,  # Currently used only by LDAP
        'required': False,
        'autoverify': False,
        'automoderate': not astakos_settings.MODERATION_ENABLED
    }

    # Mapping of provider's attributes to attributes of AstakosUser.
    # The second element of the tuple dictates whether the attribute can be
    # changed by the user or is automatically set by the provider in every
    # login.
    # Identifier is used to get the unique user identifier of the third
    # party provider!
    user_attr_map = {
        # 'user field': ('provider field', 'mutable by user')
        'identifier': ('uuid', False),
        'email': ('email', True),
        'first_name': ('first_name', True),
        'last_name': ('last_name', True),
    }

    policies = {}

    def __init__(self, user=None, identifier=None, **provider_params):
        """
        3 ways to initialize (no args, user, user and identifier).

        no args: Used for anonymous unauthenticated users.
        >>> p = auth_providers.get_provider('local')
        >>> # check that global settings allows us to create a new account
        >>> # using `local` provider.
        >>> print p.is_available_for_create()

        user and identifier: Used to provide details about a user's specific
        login method.
        >>> p = auth_providers.get_provider('google', user,
        >>>                                 identifier='1421421')
        >>> # provider (google) details prompt
        >>> print p.get_method_details()
        "Google account: 1421421"
        """

#.........这里部分代码省略.........
开发者ID:grnet,项目名称:synnefo,代码行数:103,代码来源:auth_providers.py

示例2: AuthProvider

# 需要导入模块: from synnefo.lib.ordereddict import OrderedDict [as 别名]
# 或者: from synnefo.lib.ordereddict.OrderedDict import get [as 别名]
class AuthProvider(object):

    __metaclass__ = AuthProviderBase

    module = None
    module_enabled = False
    is_primary = False

    message_tpls = OrderedDict((
        ('title', '{module_title}'),
        ('login_title', '{title} LOGIN'),
        ('method_prompt', '{title} login'),
        ('account_prompt', '{title} account'),
        ('signup_title', '{title}'),
        ('profile_title', '{title}'),
        ('method_details', '{account_prompt}: {identifier}'),
        ('primary_login_prompt', 'Login using '),
        ('required', '{title} is required. You can assign it '
                     'from your profile page'),
        ('login_prompt', ''),
        ('add_prompt', 'Allows you to login using {title}'),
        ('login_extra', ''),
        ('username', '{username}'),
        ('disabled_for_create', 'It seems this is the first time you\'re '
                                'trying to access {service_name}. '
                                'Unfortunately, we are not accepting new '
                                'users at this point.'),
        ('switch_success', 'Account changed successfully.'),
        ('cannot_login', '{title} is not available for login. '
                         'Please use one of your other available methods '
                         'to login ({available_methods_links}'),

        # icons should end with _icon
        ('module_medium_icon', 'im/auth/icons-medium/{module}.png'),
        ('module_icon', 'im/auth/icons/{module}.png'))
    )

    messages = {}
    module_urls = {}

    remote_authenticate = True
    remote_logout_url = None

    # templates
    primary_login_template = 'im/auth/generic_primary_login.html'
    login_template = 'im/auth/generic_login.html'
    signup_template = 'im/signup.html'
    login_prompt_template = 'im/auth/generic_login_prompt.html'
    signup_prompt_template = 'im/auth/signup_prompt.html'

    default_policies = {
        'login': True,
        'create': True,
        'add': True,
        'remove': True,
        'limit': 1,
        'switch': True,
        'add_groups': [],
        'creation_groups': [],
        'required': False,
        'automoderate': not astakos_settings.MODERATION_ENABLED
    }

    policies = {}

    def __init__(self, user=None, identifier=None, **provider_params):
        """
        3 ways to initialize (no args, user, user and identifier).

        no args: Used for anonymous unauthenticated users.
        >>> p = auth_providers.get_provider('local')
        >>> # check that global settings allows us to create a new account
        >>> # using `local` provider.
        >>> print p.is_available_for_create()

        user and identifier: Used to provide details about a user's specific
        login method.
        >>> p = auth_providers.get_provider('google', user,
        >>>                                 identifier='1421421')
        >>> # provider (google) details prompt
        >>> print p.get_method_details()
        "Google account: 1421421"
        """

        # handle AnonymousUser instance
        self.user = None
        if user and hasattr(user, 'pk') and user.pk:
            self.user = user

        self.identifier = identifier
        self._instance = None
        if 'instance' in provider_params:
            self._instance = provider_params['instance']
            del provider_params['instance']

        # initialize policies
        self.module_policies = copy.copy(self.default_policies)
        self.module_policies['automoderate'] = not \
            astakos_settings.MODERATION_ENABLED
        for policy, value in self.policies.iteritems():
#.........这里部分代码省略.........
开发者ID:jaeko44,项目名称:synnefo,代码行数:103,代码来源:auth_providers.py

示例3: AuthProvider

# 需要导入模块: from synnefo.lib.ordereddict import OrderedDict [as 别名]
# 或者: from synnefo.lib.ordereddict.OrderedDict import get [as 别名]
class AuthProvider(object):

    __metaclass__ = AuthProviderBase

    module = None
    module_enabled = False
    is_primary = False

    message_tpls = OrderedDict(
        (
            ("title", "{module_title}"),
            ("login_title", "{title} LOGIN"),
            ("method_prompt", "{title} login"),
            ("account_prompt", "{title} account"),
            ("signup_title", "{title}"),
            ("profile_title", "{title}"),
            ("method_details", "{account_prompt}: {identifier}"),
            ("primary_login_prompt", "Login using "),
            ("required", "{title} is required. You can assign it " "from your profile page"),
            ("login_prompt", ""),
            ("add_prompt", "Allows you to login using {title}"),
            ("login_extra", ""),
            ("username", "{username}"),
            (
                "disabled_for_create",
                "It seems this is the first time you're "
                "trying to access {service_name}. "
                "Unfortunately, we are not accepting new "
                "users at this point.",
            ),
            ("switch_success", "Account changed successfully."),
            (
                "cannot_login",
                "{title} is not available for login. "
                "Please use one of your other available methods "
                "to login ({available_methods_links}",
            ),
            # icons should end with _icon
            ("module_medium_icon", "im/auth/icons-medium/{module}.png"),
            ("module_icon", "im/auth/icons/{module}.png"),
        )
    )

    messages = {}
    module_urls = {}

    remote_authenticate = True
    remote_logout_url = None

    # templates
    primary_login_template = "im/auth/generic_primary_login.html"
    login_template = "im/auth/generic_login.html"
    signup_template = "im/signup.html"
    login_prompt_template = "im/auth/generic_login_prompt.html"
    signup_prompt_template = "im/auth/signup_prompt.html"

    default_policies = {
        "login": True,
        "create": True,
        "add": True,
        "remove": True,
        "limit": 1,
        "switch": True,
        "add_groups": [],
        "creation_groups": [],
        "required": False,
        "automoderate": not astakos_settings.MODERATION_ENABLED,
    }

    policies = {}

    def __init__(self, user=None, identifier=None, **provider_params):
        """
        3 ways to initialize (no args, user, user and identifier).

        no args: Used for anonymous unauthenticated users.
        >>> p = auth_providers.get_provider('local')
        >>> # check that global settings allows us to create a new account
        >>> # using `local` provider.
        >>> print p.is_available_for_create()

        user and identifier: Used to provide details about a user's specific
        login method.
        >>> p = auth_providers.get_provider('google', user,
        >>>                                 identifier='1421421')
        >>> # provider (google) details prompt
        >>> print p.get_method_details()
        "Google account: 1421421"
        """

        # handle AnonymousUser instance
        self.user = None
        if user and hasattr(user, "pk") and user.pk:
            self.user = user

        self.identifier = identifier
        self._instance = None
        if "instance" in provider_params:
            self._instance = provider_params["instance"]
            del provider_params["instance"]
#.........这里部分代码省略.........
开发者ID:jbd,项目名称:synnefo,代码行数:103,代码来源:auth_providers.py


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