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


Python Site.get方法代码示例

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


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

示例1: login_recovery

# 需要导入模块: from models import Site [as 别名]
# 或者: from models.Site import get [as 别名]
def login_recovery(site, host, netloc, csrf):
    """
    Recovery post url
    """

    # Logout
    session = request.environ.get('beaker.session')
    session['logged_in'] = False
    session['user_id_logged_in'] = None

    # POST parameters
    email = request.POST.getunicode('email')

    # User
    try:
        user = User.get(User.email == email)
    except User.DoesNotExist:
        return dict(status=False, info='Usuário não encontrado')

    # Site
    try:
        site = Site.get(Site.user == user)
    except Site.DoesNotExist:
        return dict(status=False, info='Site não encontrado')

    # Send recovery email
    send_recovery_email(host, DEFAULT_SENDER, user)

    # Return OK
    return dict(status=True, info='Solicitado senha com sucesso. Acesse seu email para recuperar sua senha.')
开发者ID:jfmedeirosneto,项目名称:opcms,代码行数:32,代码来源:opcms_login.py

示例2: user_recovery_page

# 需要导入模块: from models import Site [as 别名]
# 或者: from models.Site import get [as 别名]
def user_recovery_page(site, host, netloc, csrf, user_id, user_hash):
    """
    User recovery page url
    """

    # Logout
    session = request.environ.get('beaker.session')
    session['logged_in'] = False
    session['user_id_logged_in'] = None

    # User
    try:
        user = User.get(User.id == user_id, User.user_hash == user_hash)
    except User.DoesNotExist:
        return dict(site=site, host=host, csrf=csrf, recovery=False)

    # Site
    try:
        site = Site.get(Site.user == user)
    except Site.DoesNotExist:
        return dict(site=site, host=host, csrf=csrf, recovery=False)

    # Verify actived user and actived site
    if (not user.active) or (not site.active):
        return dict(site=site, host=host, csrf=csrf, recovery=False)

    # Login
    session['logged_in'] = True
    session['user_id_logged_in'] = user.get_id()

    # Return OK
    return dict(site=site, host=host, csrf=csrf, recovery=True, user=user)
开发者ID:jfmedeirosneto,项目名称:opcms,代码行数:34,代码来源:opcms_user.py

示例3: user_recovery

# 需要导入模块: from models import Site [as 别名]
# 或者: from models.Site import get [as 别名]
def user_recovery(site, host, netloc, csrf, logged_in, user_id_logged_in):
    """
    User recovery post url
    """

    # POST parameters
    user_id = int(request.POST.getunicode('id'))
    password1 = request.POST.getunicode('password1')
    password2 = request.POST.getunicode('password2')

    # Verify user
    if user_id_logged_in != user_id:
        # Logout
        session = request.environ.get('beaker.session')
        session['logged_in'] = False
        session['user_id_logged_in'] = None

        # Return error
        return dict(status=False, info='Sem permissão para acessar')

    # Verify password
    if password1 != password2:
        return dict(status=False, info='Senhas não coincidem')

    # User
    try:
        user = User.get(User.id == user_id)
    except User.DoesNotExist:
        return dict(status=False, info='Usuário não encontrado')

    # Site
    try:
        site = Site.get(Site.user == user)
    except Site.DoesNotExist:
        return dict(status=False, info='Site não encontrado')

    # Update user password
    try:
        if len(password1) > 0:
            user.password = md5(password1.encode('utf-8')).hexdigest()
        user.save()
    except IntegrityError as exp:
        # Return error
        return dict(status=False, info='%s' % exp)

    # Return OK
    return dict(status=True, info='Atualizado com sucesso')
开发者ID:jfmedeirosneto,项目名称:opcms,代码行数:49,代码来源:opcms_user.py

示例4: wrapper

# 需要导入模块: from models import Site [as 别名]
# 或者: from models.Site import get [as 别名]
        def wrapper(*args, **kwargs):
            # Request host
            scheme = request.urlparts.scheme
            netloc = request.urlparts.netloc

            # Normalized host
            host = '%s://%s' % (scheme, netloc)
            if netloc.startswith('www.'):
                netloc = netloc[4:]
            normalized_host = 'http://%s' % netloc

            # Get site information
            try:
                site = Site.get(Site.id == 1)
            except Site.DoesNotExist:
                msg = 'Site %s não existe neste servidor' % host
                if json_response:
                    return dict(status=False, info=msg)
                else:
                    abort(404, msg)

            # callback function with site and host arguments injected
            kwargs.update({'site': site, 'host': host, 'netloc': netloc})
            return func(*args, **kwargs)
开发者ID:jfmedeirosneto,项目名称:opcms,代码行数:26,代码来源:decorators.py

示例5: test_Create_Site

# 需要导入模块: from models import Site [as 别名]
# 或者: from models.Site import get [as 别名]
 def test_Create_Site(self):
   site = create_dummy_site()
   test_title = site.title
   site.save()
   site = Site.get(Site.title == test_title)
   self.assertEqual(site.uuid, site.uuid)
开发者ID:jrigden,项目名称:muckamuck,代码行数:8,代码来源:test_models.py

示例6: print

# 需要导入模块: from models import Site [as 别名]
# 或者: from models.Site import get [as 别名]

"""
Dinamic data
"""
modules_list = None
templates_dict = None

"""
Create Main Site Data
"""
MAIN_USER = None
MAIN_SITE = None
try:
    MAIN_USER = User.get(User.email == MAIN_EMAIL)
    MAIN_SITE = Site.get(Site.user == MAIN_USER)
except (User.DoesNotExist, Site.DoesNotExist) as e:
    with db.transaction():
        try:
            if not MAIN_USER:
                MAIN_USER = User.create(email=MAIN_EMAIL,
                                        password=md5(MAIN_PASSWORD.encode('utf-8')).hexdigest(),
                                        name=MAIN_NAME,
                                        active=True)
            if not MAIN_SITE:
                MAIN_SITE = Site.create(user=MAIN_USER,
                                        site_email=MAIN_EMAIL,
                                        active=True)
        except IntegrityError as ex:
            print("Main Data Fail:", ex)
开发者ID:jfmedeirosneto,项目名称:opcms,代码行数:31,代码来源:opcms.py


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