• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.module_member函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中social.utils.module_member函数的典型用法代码示例。如果您正苦于以下问题:Python module_member函数的具体用法?Python module_member怎么用?Python module_member使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: get_strategy

def get_strategy(backends, strategy, storage, request=None, backend=None, *args, **kwargs):
    if backend:
        Backend = get_backend(backends, backend)
        if not Backend:
            raise ValueError("Missing backend entry")
    else:
        Backend = None
    Strategy = module_member(strategy)
    Storage = module_member(storage)
    return Strategy(Backend, Storage, request, backends=backends, *args, **kwargs)
开发者ID:GraphAlchemist,项目名称:python-social-auth,代码行数:10,代码来源:utils.py


示例2: init_social

def init_social(app, db):
    User = module_member(app.config[setting_name('USER_MODEL')])

    database_proxy.initialize(db)

    class UserSocialAuth(PeeweeUserMixin):
        """Social Auth association model"""
        user = ForeignKeyField(User, related_name='social_auth')

        @classmethod
        def user_model(cls):
            return User

    class Nonce(PeeweeNonceMixin):
        """One use numbers"""
        pass

    class Association(PeeweeAssociationMixin):
        """OpenId account association"""
        pass

    class Code(PeeweeCodeMixin):
        pass

    # Set the references in the storage class
    FlaskStorage.user = UserSocialAuth
    FlaskStorage.nonce = Nonce
    FlaskStorage.association = Association
    FlaskStorage.code = Code
开发者ID:BeatrizFerreira,项目名称:EP1DAS,代码行数:29,代码来源:models.py


示例3: load_backends

def load_backends(backends, force_load=False):
    """
    Load backends defined on SOCIAL_AUTH_AUTHENTICATION_BACKENDS, backends will
    be imported and cached on BACKENDSCACHE. The key in that dict will be the
    backend name, and the value is the backend class.

    Only subclasses of BaseAuth (and sub-classes) are considered backends.

    Previously there was a BACKENDS attribute expected on backends modules,
    this is not needed anymore since it's enough with the
    AUTHENTICATION_BACKENDS setting. BACKENDS was used because backends used to
    be split on two classes the authentication backend and another class that
    dealt with the auth mechanism with the provider, those classes are joined
    now.

    A force_load boolean argument is also provided so that get_backend
    below can retry a requested backend that may not yet be discovered.
    """
    global BACKENDSCACHE
    if force_load:
        BACKENDSCACHE = {}
    if not BACKENDSCACHE:
        for auth_backend in backends:
            backend = module_member(auth_backend)
            if issubclass(backend, BaseAuth):
                BACKENDSCACHE[backend.name] = backend
    return BACKENDSCACHE
开发者ID:FashtimeDotCom,项目名称:flask_reveal,代码行数:27,代码来源:utils.py


示例4: get_login_providers

def get_login_providers(request, short=False):
    """
    Returns a list of available login providers based on the
    AUTHENTICATION_BACKENDS setting. Each provider is represented as a
    dictionary containing the backend name, name of required parameter if
    required and its verbose name.
    """
    def extract_backend_data(klass):
        """
        Helper function which extracts information useful for use in
        templates from SocialAuth subclasses and returns it as a
        dictionary.
        """
        return {
            'name': klass.name,
            'required_field': klass.REQUIRED_FIELD_NAME,
            'required_field_verbose': klass.REQUIRED_FIELD_VERBOSE_NAME,
        }

    backends = (module_member(auth_backend) for auth_backend in setting('AUTHENTICATION_BACKENDS'))
    providers = [extract_backend_data(backend) for backend in backends if issubclass(backend, BaseAuth)]
    if short:
        return providers[:setting('AUTHENTICATION_PROVIDERS_BRIEF',
                                  DEFAULT_AUTHENTICATION_PROVIDERS_BRIEF)]
    return providers
开发者ID:black3r,项目名称:ksp_login,代码行数:25,代码来源:context_processors.py


示例5: init_social

def init_social(config, Base, session):
    if hasattr(config, 'registry'):
        config = config.registry.settings
    UID_LENGTH = config.get(setting_name('UID_LENGTH'), 255)
    User = module_member(config[setting_name('USER_MODEL')])
    app_session = session

    class _AppSession(object):
        COMMIT_SESSION = False

        @classmethod
        def _session(cls):
            return app_session

    class UserSocialAuth(_AppSession, Base, SQLAlchemyUserMixin):
        """Social Auth association model"""
        __tablename__ = 'social_auth_usersocialauth'
        __table_args__ = (UniqueConstraint('provider', 'uid'),)
        id = Column(Integer, primary_key=True)
        provider = Column(String(32))
        uid = Column(String(UID_LENGTH))
        extra_data = Column(JSONType)
        user_id = Column(Integer, ForeignKey(User.id),
                         nullable=False, index=True)
        user = relationship(User, backref=backref('social_auth',
                                                  lazy='dynamic'))

        @classmethod
        def username_max_length(cls):
            return User.__table__.columns.get('username').type.length

        @classmethod
        def user_model(cls):
            return User

    class Nonce(_AppSession, Base, SQLAlchemyNonceMixin):
        """One use numbers"""
        __tablename__ = 'social_auth_nonce'
        __table_args__ = (UniqueConstraint('server_url', 'timestamp', 'salt'),)
        id = Column(Integer, primary_key=True)
        server_url = Column(String(255))
        timestamp = Column(Integer)
        salt = Column(String(40))

    class Association(_AppSession, Base, SQLAlchemyAssociationMixin):
        """OpenId account association"""
        __tablename__ = 'social_auth_association'
        __table_args__ = (UniqueConstraint('server_url', 'handle'),)
        id = Column(Integer, primary_key=True)
        server_url = Column(String(255))
        handle = Column(String(255))
        secret = Column(String(255))  # base64 encoded
        issued = Column(Integer)
        lifetime = Column(Integer)
        assoc_type = Column(String(64))

    # Set the references in the storage class
    PyramidStorage.user = UserSocialAuth
    PyramidStorage.nonce = Nonce
    PyramidStorage.association = Association
开发者ID:jontsai,项目名称:python-social-auth,代码行数:60,代码来源:models.py


示例6: init_social

def init_social(app, db):
    User = module_member(app.config[setting_name('USER_MODEL')])

    class UserSocialAuth(db.Document, MongoengineUserMixin):
        """Social Auth association model"""
        user = ReferenceField(User)

        @classmethod
        def user_model(cls):
            return User

    class Nonce(db.Document, MongoengineNonceMixin):
        """One use numbers"""
        pass

    class Association(db.Document, MongoengineAssociationMixin):
        """OpenId account association"""
        pass

    class Code(db.Document, MongoengineCodeMixin):
        pass

    # Set the references in the storage class
    FlaskStorage.user = UserSocialAuth
    FlaskStorage.nonce = Nonce
    FlaskStorage.association = Association
    FlaskStorage.code = Code
开发者ID:2070616d,项目名称:TP3,代码行数:27,代码来源:models.py


示例7: wrapper

 def wrapper(request, *args, **kwargs):
     is_logged_in = module_member(
         request.backend.setting('LOGGEDIN_FUNCTION')
     )
     if not is_logged_in(request):
         raise HTTPForbidden('Not authorized user')
     return func(request, *args, **kwargs)
开发者ID:Akanksha18,项目名称:Amipool,代码行数:7,代码来源:utils.py


示例8: _get_user_model

def _get_user_model():
    """
    Get the User Document class user for MongoEngine authentication.

    Use the model defined in SOCIAL_AUTH_USER_MODEL if defined, or
    defaults to MongoEngine's configured user document class.
    """
    custom_model = getattr(settings, setting_name('USER_MODEL'), None)
    if custom_model:
        return module_member(custom_model)

    try:
        # Custom user model support with MongoEngine 0.8
        from mongoengine.django.mongo_auth.models import get_user_document
        return get_user_document()
    except ImportError:
        return module_member('mongoengine.django.auth.User')
开发者ID:2070616d,项目名称:TP3,代码行数:17,代码来源:models.py


示例9: __init__

 def __init__(self, *args, **kwargs):
     self.backend = module_member(self.backend_path)
     self.complete_url = '/complete/{0}/?{1}&{2}'.format(
         self.backend.name,
         'oauth_verifier=bazqux',
         'oauth_token=foobar'
     )
     super(OAuth1Test, self).__init__(*args, **kwargs)
开发者ID:wwitzel3,项目名称:python-social-auth,代码行数:8,代码来源:oauth1.py


示例10: setUp

 def setUp(self):
     HTTPretty.enable()
     User.reset_cache()
     TestUserSocialAuth.reset_cache()
     TestNonce.reset_cache()
     TestAssociation.reset_cache()
     self.backend = module_member('social.backends.github.GithubOAuth2')
     self.strategy = TestStrategy(self.backend, TestStorage)
     self.user = None
开发者ID:0077cc,项目名称:python-social-auth,代码行数:9,代码来源:actions.py


示例11: load_backends

def load_backends(backends, force_load=False):
    global BACKENDSCACHE
    if force_load:
        BACKENDSCACHE = {}
    if not BACKENDSCACHE:
        for data_backend in backends:
            backend = module_member(data_backend)
            BACKENDSCACHE[backend.name] = backend
    return BACKENDSCACHE
开发者ID:ybbaigo,项目名称:Starcal-Server,代码行数:9,代码来源:utils.py


示例12: backends

def backends(request, user):
    """Load Social Auth current user data to context under the key 'backends'.
    Will return the output of social.backends.utils.user_backends_data."""
    storage = module_member(get_helper('STORAGE'))
    return {
        'backends': user_backends_data(
            user, get_helper('AUTHENTICATION_BACKENDS'), storage
        )
    }
开发者ID:Akanksha18,项目名称:Amipool,代码行数:9,代码来源:utils.py


示例13: setUp

 def setUp(self):
     HTTPretty.enable()
     self.backend = module_member(self.backend_path)
     self.complete_url = "/complete/{0}/".format(self.backend.name)
     self.strategy = TestStrategy(self.backend, TestStorage, redirect_uri=self.complete_url)
     self.strategy.set_settings(
         {"SOCIAL_AUTH_AUTHENTICATION_BACKENDS": (self.backend_path, "tests.backends.broken_test.BrokenBackendAuth")}
     )
     # Force backends loading to trash PSA cache
     load_backends(self.strategy.get_setting("SOCIAL_AUTH_AUTHENTICATION_BACKENDS"), force_load=True)
开发者ID:bobhsr,项目名称:python-social-auth,代码行数:10,代码来源:open_id.py


示例14: setUp

 def setUp(self):
     HTTPretty.enable()
     User.reset_cache()
     TestUserSocialAuth.reset_cache()
     TestNonce.reset_cache()
     TestAssociation.reset_cache()
     Backend = module_member("social.backends.github.GithubOAuth2")
     self.strategy = self.strategy or TestStrategy(TestStorage)
     self.backend = Backend(self.strategy, redirect_uri="/complete/github")
     self.user = None
开发者ID:humaneu,项目名称:flask_app,代码行数:10,代码来源:actions.py


示例15: init_social

def init_social(Base, session, settings):
    if TornadoStorage._AppSession is not None:
        # Initialize only once. New calls are expected to have the same Base
        # and will set the session to be the new session passed.
        assert Base == TornadoStorage._Base
        TornadoStorage._AppSession.__use_db_session__ = session
        return
    
    
    UID_LENGTH = settings.get(setting_name('UID_LENGTH'), 255)
    User = module_member(settings[setting_name('USER_MODEL')])

    class _AppSession(object):
        @classmethod
        def _session(cls):
            return _AppSession.__use_db_session__

    _AppSession.__use_db_session__ = session
    TornadoStorage._AppSession = _AppSession
    TornadoStorage._Base = Base

    class UserSocialAuth(_AppSession, Base, SQLAlchemyUserMixin):
        """Social Auth association model"""
        uid = Column(String(UID_LENGTH))
        user_id = Column(Integer, ForeignKey(User.id),
                         nullable=False, index=True)
        user = relationship(User, backref=backref('social_auth',
                                                  lazy='dynamic'))

        @classmethod
        def username_max_length(cls):
            return User.__table__.columns.get('username').type.length

        @classmethod
        def user_model(cls):
            return User

    class Nonce(_AppSession, Base, SQLAlchemyNonceMixin):
        """One use numbers"""
        pass

    class Association(_AppSession, Base, SQLAlchemyAssociationMixin):
        """OpenId account association"""
        pass

    class Code(_AppSession, Base, SQLAlchemyCodeMixin):
        pass

    # Set the references in the storage class
    TornadoStorage.user = UserSocialAuth
    TornadoStorage.nonce = Nonce
    TornadoStorage.association = Association
    TornadoStorage.code = Code
开发者ID:fabioz,项目名称:python-social-auth,代码行数:53,代码来源:models.py


示例16: run_pipeline

    def run_pipeline(self, pipeline, pipeline_index=0, *args, **kwargs):
        out = kwargs.copy()
        out.setdefault('strategy', self.strategy)
        out.setdefault('backend', out.pop(self.name, None) or self)

        for idx, name in enumerate(pipeline):
            out['pipeline_index'] = pipeline_index + idx
            func = module_member(name)
            result = func(*args, **out) or {}
            if not isinstance(result, dict):
                return result
            out.update(result)
        self.strategy.clean_partial_pipeline()
        return out
开发者ID:binarytemple,项目名称:python-social-auth,代码行数:14,代码来源:base.py


示例17: setUp

    def setUp(self):

        self.backend_module_path = "tethys_services.backends.hydroshare.HydroShareOAuth2"
        self.Backend_Class = module_member(self.backend_module_path)
        self.client_complete_url = "https://apps.hydroshare.org/complete/hydroshare/"

        self.access_token = str(uuid.uuid4())
        self.refresh_token = str(uuid.uuid4())
        self.expires_in = random.randint(1, 30 * 60 * 60)  # 1 sec to 30 days
        self.token_type = "bearer"
        self.scope = "read write"

        self.social_username = "drew"
        self.social_email = "[email protected]"
开发者ID:SarvaPulla,项目名称:tethys,代码行数:14,代码来源:test_hydroshare.py


示例18: get_username

def get_username(strategy, details, user=None, *args, **kwargs):
    if 'username' not in strategy.setting('USER_FIELDS', USER_FIELDS):
        return
    storage = strategy.storage

    if not user:
        email_as_username = strategy.setting('USERNAME_IS_FULL_EMAIL', False)
        uuid_length = strategy.setting('UUID_LENGTH', 16)
        max_length = storage.user.username_max_length()
        do_slugify = strategy.setting('SLUGIFY_USERNAMES', False)
        do_clean = strategy.setting('CLEAN_USERNAMES', True)

        if do_clean:
            clean_func = storage.user.clean_username
        else:
            clean_func = lambda val: val

        if do_slugify:
            override_slug = strategy.setting('SLUGIFY_FUNCTION')
            if override_slug:
                slug_func = module_member(override_slug)
            else:
                slug_func = slugify
        else:
            slug_func = lambda val: val

        if email_as_username and details.get('email'):
            username = details['email']
        elif details.get('username'):
            username = details['username']
        else:
            username = uuid4().hex

        short_username = (username[:max_length - uuid_length]
                          if max_length is not None
                          else username)
        final_username = slug_func(clean_func(username[:max_length]))

        # Generate a unique username for current user using username
        # as base but adding a unique hash at the end. Original
        # username is cut to avoid any field max_length.
        # The final_username may be empty and will skip the loop.
        while not final_username or \
              storage.user.user_exists(username=final_username):
            username = short_username + uuid4().hex[:uuid_length]
            final_username = slug_func(clean_func(username[:max_length]))
    else:
        final_username = storage.user.get_username(user)
    return {'username': final_username}
开发者ID:BeatrizFerreira,项目名称:EP1DAS,代码行数:49,代码来源:user.py


示例19: setUp

 def setUp(self):
     HTTPretty.enable()
     self.backend = module_member(self.backend_path)
     self.strategy = TestStrategy(self.backend, TestStorage)
     self.name = self.backend.name.upper().replace("-", "_")
     self.complete_url = self.strategy.build_absolute_uri(self.raw_complete_url.format(self.backend.name))
     backends = (self.backend_path, "social.tests.backends.test_broken.BrokenBackendAuth")
     self.strategy.set_settings({"SOCIAL_AUTH_AUTHENTICATION_BACKENDS": backends})
     self.strategy.set_settings(self.extra_settings())
     # Force backends loading to trash PSA cache
     load_backends(backends, force_load=True)
     User.reset_cache()
     TestUserSocialAuth.reset_cache()
     TestNonce.reset_cache()
     TestAssociation.reset_cache()
     TestCode.reset_cache()
开发者ID:relsi,项目名称:w2p-social-auth,代码行数:16,代码来源:base.py


示例20: init_social

def init_social(config, Base, session):
    if hasattr(config, 'registry'):
        config = config.registry.settings
    UID_LENGTH = config.get(setting_name('UID_LENGTH'), 255)
    User = module_member(config[setting_name('USER_MODEL')])
    app_session = session

    class _AppSession(object):
        COMMIT_SESSION = False

        @classmethod
        def _session(cls):
            return app_session

    class UserSocialAuth(_AppSession, Base, SQLAlchemyUserMixin):
        """Social Auth association model"""
        uid = Column(String(UID_LENGTH))
        user_id = Column(Integer, ForeignKey(User.id),
                         nullable=False, index=True)
        user = relationship(User, backref=backref('social_auth',
                                                  lazy='dynamic'))

        @classmethod
        def username_max_length(cls):
            return User.__table__.columns.get('username').type.length

        @classmethod
        def user_model(cls):
            return User

    class Nonce(_AppSession, Base, SQLAlchemyNonceMixin):
        """One use numbers"""
        pass

    class Association(_AppSession, Base, SQLAlchemyAssociationMixin):
        """OpenId account association"""
        pass

    class Code(_AppSession, Base, SQLAlchemyCodeMixin):
        pass

    # Set the references in the storage class
    PyramidStorage.user = UserSocialAuth
    PyramidStorage.nonce = Nonce
    PyramidStorage.association = Association
    PyramidStorage.code = Code
开发者ID:ALASTAIR29,项目名称:python-social-auth,代码行数:46,代码来源:models.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.parse_qs函数代码示例发布时间:2022-05-27
下一篇:
Python utils.getRequestArg函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap