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


Python utils.setting_name函数代码示例

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


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

示例1: 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

示例2: setting

 def setting(self, name, default=None):
     setting = default
     names = (setting_name(self.backend.titled_name, name), setting_name(name), name)
     for name in names:
         try:
             return self.get_setting(name)
         except (AttributeError, KeyError):
             pass
     return setting
开发者ID:relsi,项目名称:python-social-auth,代码行数:9,代码来源:base.py

示例3: setting

 def setting(self, name, default=None, backend=None):
     names = [setting_name(name), name]
     if backend:
         names.insert(0, setting_name(backend.name, name))
     for name in names:
         try:
             return self.get_setting(name)
         except (AttributeError, KeyError):
             pass
     return default
开发者ID:BeatrizFerreira,项目名称:EP1DAS,代码行数:10,代码来源:base.py

示例4: init_social

def init_social(app, session):
    UID_LENGTH = app.config.get(setting_name('UID_LENGTH'), 255)
    User = module_member(app.config[setting_name('USER_MODEL')])
    _AppSession._set_session(session)
    UserSocialAuth.__table_args__ = (UniqueConstraint('provider', 'uid'),)
    UserSocialAuth.uid = Column(String(UID_LENGTH))
    UserSocialAuth.user_id = Column(Integer, ForeignKey(User.id),
                                    nullable=False, index=True)
    UserSocialAuth.user = relationship(User, backref=backref('social_auth',
                                                             lazy='dynamic'))
开发者ID:2070616d,项目名称:TP3,代码行数:10,代码来源:models.py

示例5: 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

示例6: 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

示例7: setting

 def setting(self, name, default=None):
     for name in (setting_name(name), name):
         try:
             return self.get_setting(name)
         except (AttributeError, KeyError):
             pass
     return default
开发者ID:noirbizarre,项目名称:python-social-auth,代码行数:7,代码来源:base.py

示例8: setting

 def setting(self, name, default=None):
     """Return setting value from strategy"""
     _default = object()
     for name in (setting_name(self.name, name), name):
         value = self.strategy.setting(name, _default)
         if value != _default:
             return value
     return default
开发者ID:AppsFuel,项目名称:python-social-auth,代码行数:8,代码来源:base.py

示例9: 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

示例10: setup_social_auth

def setup_social_auth():
	web.config[setting_name('GOOGLE_OAUTH2_KEY')] = oauth2_key
	web.config[setting_name('GOOGLE_OAUTH2_SECRET')] = oauth2_secret
	web.config[setting_name('USER_MODEL')] = 'models.user.User'
	web.config[setting_name('AUTHENTICATION_BACKENDS')] = (
	    'social.backends.google.GoogleOAuth2',
	    )
	# TODO: change following two lines on deployment
	web.config[setting_name('NEW_USER_REDIRECT_URL')] = '/openid/#/edit'
	web.config[setting_name('LOGIN_REDIRECT_URL')] = '/openid/'
	web.config[setting_name('SANITIZE_REDIRECTS')] = False
开发者ID:cccarey,项目名称:backbone-webpy-openid,代码行数:11,代码来源:__init__.py

示例11: get_search_fields

 def get_search_fields(self):
     search_fields = getattr(
         settings, setting_name('ADMIN_USER_SEARCH_FIELDS'), None
     )
     if search_fields is None:
         _User = UserSocialAuth.user_model()
         username = getattr(_User, 'USERNAME_FIELD', None) or \
                    hasattr(_User, 'username') and 'username' or \
                    None
         fieldnames = ('first_name', 'last_name', 'email', username)
         all_names = _User._meta.get_all_field_names()
         search_fields = [name for name in fieldnames
                             if name and name in all_names]
     return ['user_' + name for name in search_fields]
开发者ID:AlfiyaZi,项目名称:python-social-auth,代码行数:14,代码来源:admin.py

示例12: _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

示例13: getattr

from functools import wraps

from django.conf import settings
from django.core.urlresolvers import reverse

from social.utils import setting_name, module_member
from social.strategies.utils import get_strategy


BACKENDS = settings.AUTHENTICATION_BACKENDS
STRATEGY = getattr(settings, setting_name('STRATEGY'),
                   'social.strategies.django_strategy.DjangoStrategy')
STORAGE = getattr(settings, setting_name('STORAGE'),
                  'social.apps.django_app.default.models.DjangoStorage')
Strategy = module_member(STRATEGY)
Storage = module_member(STORAGE)


def load_strategy(*args, **kwargs):
    return get_strategy(BACKENDS, STRATEGY, STORAGE, *args, **kwargs)


def strategy(redirect_uri=None, load_strategy=load_strategy):
    def decorator(func):
        @wraps(func)
        def wrapper(request, backend, *args, **kwargs):
            uri = redirect_uri
            if uri and not uri.startswith('/'):
                uri = reverse(redirect_uri, args=(backend,))
            request.strategy = load_strategy(request=request, backend=backend,
                                             redirect_uri=uri, *args, **kwargs)
开发者ID:AppsFuel,项目名称:python-social-auth,代码行数:31,代码来源:utils.py

示例14: getattr

'''
Project: Farnsworth

Author: Karandeep Singh Nagra
'''

from django.conf import settings
from django.db import models
from django.contrib.auth.models import User, Group, Permission

from phonenumber_field.modelfields import PhoneNumberField

from social.utils import setting_name

UID_LENGTH = getattr(settings, setting_name('UID_LENGTH'), 255)

class UserProfile(models.Model):
    '''
    The UserProfile model.  Tied to a unique User.  Contains e-mail settings
    and phone number.
    '''
    user = models.OneToOneField(User)
    former_houses = models.CharField(
        blank=True,
        null=True,
        max_length=100,
        help_text="List of user's former BSC houses",
        )
    phone_number = PhoneNumberField(
        null=True,
        blank=True,
开发者ID:nherson,项目名称:farnsworth,代码行数:31,代码来源:models.py

示例15: getattr

"""Django ORM models for Social Auth"""
from django.db import models
from django.conf import settings
from django.db.utils import IntegrityError

from social.utils import setting_name
from social.storage.django_orm import DjangoUserMixin, \
                                      DjangoAssociationMixin, \
                                      DjangoNonceMixin, \
                                      DjangoCodeMixin, \
                                      BaseDjangoStorage
from social.apps.django_app.default.fields import JSONField


USER_MODEL = getattr(settings, setting_name('USER_MODEL'), None) or \
             getattr(settings, 'AUTH_USER_MODEL', None) or \
             'auth.User'
UID_LENGTH = getattr(settings, setting_name('UID_LENGTH'), 255)
NONCE_SERVER_URL_LENGTH = getattr(
    settings, setting_name('NONCE_SERVER_URL_LENGTH'), 255)
ASSOCIATION_SERVER_URL_LENGTH = getattr(
    settings, setting_name('ASSOCIATION_SERVER_URL_LENGTH'), 255)
ASSOCIATION_HANDLE_LENGTH = getattr(
    settings, setting_name('ASSOCIATION_HANDLE_LENGTH'), 255)


class UserSocialAuth(models.Model, DjangoUserMixin):
    """Social Auth association model"""
    user = models.ForeignKey(USER_MODEL, related_name='social_auth')
    provider = models.CharField(max_length=32)
    uid = models.CharField(max_length=UID_LENGTH)
开发者ID:Diolor,项目名称:python-social-auth,代码行数:31,代码来源:models.py


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