當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。