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

Python utils.setting_name函数代码示例

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

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



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


示例16: get_helper

def get_helper(name, do_import=False):
    config = web.config.get(setting_name(name),
                            DEFAULTS.get(name, None))
    return do_import and module_member(config) or config
开发者ID:Charlesdong,项目名称:python-social-auth,代码行数:4,代码来源:utils.py


示例17: module_member

                        StringField, EmailField, BooleanField
from mongoengine.queryset import OperationError

from social.utils import setting_name, module_member
from social.storage.django_orm import DjangoUserMixin, \
                                      DjangoAssociationMixin, \
                                      DjangoNonceMixin, \
                                      DjangoCodeMixin, \
                                      BaseDjangoStorage


UNUSABLE_PASSWORD = '!'  # Borrowed from django 1.4


USER_MODEL = module_member(
    getattr(settings, setting_name('USER_MODEL'), None) or
    getattr(settings, 'AUTH_USER_MODEL', None) or
    'mongoengine.django.auth.User'
)


class UserSocialAuth(Document, DjangoUserMixin):
    """Social Auth association model"""
    user = ReferenceField(USER_MODEL, dbref=True)
    provider = StringField(max_length=32)
    uid = StringField(max_length=255, unique_with='provider')
    extra_data = DictField()

    def str_id(self):
        return str(self.id)
开发者ID:devvine,项目名称:python-social-auth,代码行数:30,代码来源:models.py


示例18: complete

 def complete(self, backend, *args, **kwargs):
     login = cherrypy.config.get(setting_name('LOGIN_METHOD'))
     do_login = module_member(login) if login else self.do_login
     user = getattr(cherrypy.request, 'user', None)
     return do_complete(self.strategy, do_login, user=user, *args, **kwargs)
开发者ID:nozuono,项目名称:calibre-webserver,代码行数:5,代码来源:auth.py


示例19: url

Including another URLconf
    1. Add an import:  from blog import urls as blog_urls
    2. Add a URL to urlpatterns:  url(r'^blog/', include(blog_urls))
"""
from django.conf.urls import include, url, patterns
from django.contrib import admin
from django.conf import settings
from django.conf.urls.static import static

from ui.views import Index, logout
from api.views_ui import redirect_ui
from social.utils import setting_name
from social.apps.django_app.views import complete
from edx_proctor_webassistant.decorators import set_token_cookie

extra = getattr(settings, setting_name('TRAILING_SLASH'), True) and '/' or ''

urlpatterns = patterns(
    '',
    url(r'^$', Index.as_view(), name="index"),
    url(r'^grappelli/', include('grappelli.urls')),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^api/', include('api.urls')),

    # few angular views
    url(r'^session/', redirect_ui),
    url(r'^archive/', redirect_ui),

    url(r'^complete/(?P<backend>[^/]+){0}$'.format(extra), set_token_cookie(complete),
        name='complete'),
    url('', include('social.apps.django_app.urls', namespace='social')),
开发者ID:npoed,项目名称:edx_proctor_webassistant,代码行数:31,代码来源:urls.py


示例20:

sys.path.append('../..')

import web
from web.contrib.template import render_jinja

from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker

from social.utils import setting_name
from social.apps.webpy_app.utils import strategy, backends
from social.apps.webpy_app import app as social_app

import local_settings

web.config.debug = False
web.config[setting_name('USER_MODEL')] = 'models.User'
web.config[setting_name('AUTHENTICATION_BACKENDS')] = (
    'social.backends.open_id.OpenIdAuth',
    'social.backends.google.GoogleOpenId',
    'social.backends.google.GoogleOAuth2',
    'social.backends.google.GoogleOAuth',
    'social.backends.twitter.TwitterOAuth',
    'social.backends.yahoo.YahooOpenId',
    'social.backends.stripe.StripeOAuth2',
    'social.backends.persona.PersonaAuth',
    'social.backends.facebook.FacebookOAuth2',
    'social.backends.facebook.FacebookAppOAuth2',
    'social.backends.yahoo.YahooOAuth',
    'social.backends.angel.AngelOAuth2',
    'social.backends.behance.BehanceOAuth2',
    'social.backends.bitbucket.BitbucketOAuth',
开发者ID:kazarinov,项目名称:python-social-auth,代码行数:31,代码来源:app.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python utils.user_is_active函数代码示例发布时间:2022-05-27
下一篇:
Python utils.sanitize_redirect函数代码示例发布时间: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