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


Python web.seeother函数代码示例

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


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

示例1: callback

def callback():
    i = ctx.request.input(code="")
    code = i.code
    client = _create_client()
    r = client.request_access_token(code)
    logging.info("access token: %s" % json.dumps(r))
    access_token, expires_in, uid = r.access_token, r.expires_in, r.uid
    client.set_access_token(access_token, expires_in)
    u = client.users.show.get(uid=uid)
    logging.info("got user: %s" % uid)
    users = db.select("select * from users where id=?", uid)
    user = dict(
        name=u.screen_name,
        image_url=u.avatar_large or u.profile_image_url,
        statuses_count=u.statuses_count,
        friends_count=u.friends_count,
        followers_count=u.followers_count,
        verified=u.verified,
        verified_type=u.verified_type,
        auth_token=access_token,
        expired_time=expires_in,
    )
    if users:
        db.update_kw("users", "id=?", uid, **user)
    else:
        user["id"] = uid
        db.insert("users", **user)
    _make_cookie(uid, access_token, expires_in)
    raise seeother("/")
开发者ID:zhourunlai,项目名称:soulmatetest,代码行数:29,代码来源:urls.py

示例2: callback

def callback():
    i = ctx.request.input(code='')
    code = i.code
    client = _create_client()
    r = client.request_access_token(code)
    logging.info('access token: %s' % json.dumps(r))
    access_token, expires_in, uid = r.access_token, r.expires_in, r.uid
    client.set_access_token(access_token, expires_in)
    u = client.users.show.get(uid=uid)
    logging.info('got user: %s' % uid)
    users = db.select('select * from users where id=?', uid)
    user = dict(name=u.screen_name, \
            image_url=u.avatar_large or u.profile_image_url, \
            statuses_count=u.statuses_count, \
            friends_count=u.friends_count, \
            followers_count=u.followers_count, \
            verified=u.verified, \
            verified_type=u.verified_type, \
            auth_token=access_token, \
            expired_time=expires_in)
    if users:
        db.update_kw('users', 'id=?', uid, **user)
    else:
        user['id'] = uid
        db.insert('users', **user)
    _make_cookie(uid, access_token, expires_in)
    raise seeother('/')
开发者ID:kaiwang13,项目名称:SOA_HW,代码行数:27,代码来源:urls.py

示例3: auth_signin

def auth_signin():
    '''
    Redirect to sina sign in page.
    '''
    ctx.response.set_cookie(COOKIE_REDIRECT, _get_referer())
    client = APIClient(app_key=APP_KEY, app_secret=APP_SECRET, redirect_uri=CALLBACK)
    raise seeother(client.get_authorize_url())
开发者ID:michaelliao,项目名称:shi-ci,代码行数:7,代码来源:apis.py

示例4: signout

def signout():
    delete_session_cookie()
    redirect = ctx.request.get('redirect', '')
    if not redirect:
        redirect = ctx.request.header('REFERER', '')
    if not redirect or redirect.find('/admin/')!=(-1) or redirect.find('/signin')!=(-1):
        redirect = '/'
    logging.debug('signed out and redirect to: %s' % redirect)
    raise seeother(redirect)
开发者ID:michaelliao,项目名称:brightercv,代码行数:9,代码来源:auth.py

示例5: pages

def pages():
    i = ctx.request.input(action='')
    if i.action=='edit':
        page = _get_page(i.id)
        return Template('/templates/articleform.html', form_title=_('Edit Page'), form_action='/api/pages/update', static=True, **page)
    if i.action=='delete':
        api_delete_page()
        raise seeother('pages')
    return Template('templates/pages.html', pages=_get_pages())
开发者ID:a740122,项目名称:itranswarp,代码行数:9,代码来源:__init__.py

示例6: categories

def categories():
    i = ctx.request.input(action='')
    if i.action=='add':
        return Template('templates/categoryform.html', form_title=_('Add Category'), form_action='/api/categories/create')
    if i.action=='edit':
        cat = _get_category(i.id)
        return Template('templates/categoryform.html', form_title=_('Edit Category'), form_action='/api/categories/update', **cat)
    if i.action=='delete':
        api_delete_category()
        raise seeother('categories')
    return Template('templates/categories.html', categories=_get_categories())
开发者ID:a740122,项目名称:itranswarp,代码行数:11,代码来源:__init__.py

示例7: auth_callback

def auth_callback():
    '''
    Callback from sina, then redirect to previous url.
    '''
    code = ctx.request.input(code='').code
    if not code:
        raise seeother('/s/auth_failed')
    client = APIClient(app_key=APP_KEY, app_secret=APP_SECRET, redirect_uri=CALLBACK)
    r = client.request_access_token(code)
    access_token = r.access_token
    expires = r.expires_in
    uid = r.uid
    # get user info:
    client.set_access_token(access_token, expires)
    account = client.users.show.get(uid=uid)
    image = account.get(u'profile_image_url', u'about:blank')
    logging.info('got account: %s' % str(account))
    name = account.get('screen_name', u'') or account.get('name', u'')

    id = u'weibo_%s' % uid
    user = auth.fn_load_user(id)
    if user:
        # update user if necessary:
        db.update('update user set name=?, oauth_image=?, oauth_access_token=?, oauth_expires=? where id=?', \
                name, image, access_token, expires, id)
    else:
        db.insert('user', \
                id = id, \
                name = name, \
                oauth_access_token = access_token, \
                oauth_expires = expires, \
                oauth_url = u'http://weibo.com/u/%s' % uid, \
                oauth_image = image, \
                admin = False)
    # make a signin cookie:
    cookie_str = auth.make_session_cookie(id, access_token, expires)
    logging.info('will set cookie: %s' % cookie_str)
    redirect = ctx.request.cookie(COOKIE_REDIRECT, '/')
    ctx.response.set_cookie(auth.COOKIE_AUTH, cookie_str, expires=expires)
    ctx.response.delete_cookie(COOKIE_REDIRECT)
    raise seeother(redirect)
开发者ID:michaelliao,项目名称:shi-ci,代码行数:41,代码来源:apis.py

示例8: manage_interceptor

def manage_interceptor(next):
    """

    :param next:
    :return: :raise seeother:
    """
    user = ctx.request.user
    if user:
        localauth = LocalAuth.find_first('where user_id=?', user.user_id)
        if localauth.user_admin:
            return next()
    raise seeother('/signin')
开发者ID:edwingoo,项目名称:mywebapp,代码行数:12,代码来源:urls.py

示例9: _manage

def _manage(app, func):
    if ctx.user is None:
        raise seeother('/auth/signin')
    mod = _apps.get(app, None)
    if mod is None:
        raise notfound()
    fn = getattr(mod, func, None)
    if fn is None:
        raise notfound()
    r = fn()
    if isinstance(r, Template):
        r.model['__user__'] = ctx.user
        r.model['__apps__'] = _apps_list
        return r
开发者ID:michaelliao,项目名称:brighterpage,代码行数:14,代码来源:manage.py

示例10: articles

def articles():
    i = ctx.request.input(action='', page='1')
    if i.action=='edit':
        article = _get_article(i.id)
        return Template('templates/articleform.html', form_title=_('Edit Article'), form_action='/api/articles/update', categories=_get_categories(), static=False, **article)
    if i.action=='delete':
        api_delete_article()
        raise seeother('articles')
    page = int(i.page)
    previous = page > 1
    next = False
    articles = _get_articles(page, 51, published_only=False)
    if len(articles)==51:
        articles = articles[:-1]
        next = True
    return Template('templates/articles.html', page=page, previous=previous, next=next, categories=_get_categories(), articles=articles)
开发者ID:a740122,项目名称:itranswarp,代码行数:16,代码来源:__init__.py

示例11: do_signin

def do_signin():
    i = ctx.request.input(remember='')
    email = i.email.strip().lower()
    passwd = i.passwd
    remember = i.remember
    if not email or not passwd:
        return dict(email=email, remember=remember, error=_('Bad email or password'))
    us = db.select('select id, passwd from users where email=?', email)
    if not us:
        return dict(email=email, remember=remember, error=_('Bad email or password'))
    u = us[0]
    if passwd != u.passwd:
        logging.debug('expected passwd: %s' % u.passwd)
        return dict(email=email, remember=remember, error=_('Bad email or password'))
    expires = time.time() + _SESSION_COOKIE_EXPIRES if remember else None
    make_session_cookie(u.id, passwd, expires)
    ctx.response.delete_cookie(_COOKIE_SIGNIN_REDIRECT)
    raise seeother(ctx.request.cookie(_COOKIE_SIGNIN_REDIRECT, '/'))
开发者ID:michaelliao,项目名称:rtmp-livestreaming,代码行数:18,代码来源:auth.py

示例12: attachments

def attachments():
    i = ctx.request.input(action='', page='1', size='20')
    if i.action=='delete':
        delete_attachment(i.id)
        raise seeother('attachments')
    page = int(i.page)
    size = int(i.size)
    num = db.select_int('select count(id) from attachments where website_id=?', ctx.website.id)
    if page < 1:
        raise APIValueError('page', 'page invalid.')
    if size < 1 or size > 100:
        raise APIValueError('size', 'size invalid.')
    offset = (page - 1) * size
    atts = db.select('select * from attachments where website_id=? order by id desc limit ?,?', ctx.website.id, offset, size+1)
    next = False
    if len(atts)>size:
        atts = atts[:-1]
        next = True
    return Template('templates/attachments.html', attachments=atts, page=page, previous=page>2, next=next)
开发者ID:a740122,项目名称:itranswarp,代码行数:19,代码来源:__init__.py

示例13: auth_callback_weibo

def auth_callback_weibo():
    provider = 'SinaWeibo'
    p = sns.create_client(provider)

    callback = 'http://%s/manage/setting/auth_callback_weibo' % ctx.request.host
    i = ctx.request.input(code='', state='')
    code = i.code
    if not code:
        raise IOError('missing code')
    state = i.state
    r = p.request_access_token(code, callback)
    thirdpart_id = r['uid']
    info = p.users.show.get(uid=thirdpart_id)
    name = info['screen_name']
    auth_id = '%s-%s' % (provider, thirdpart_id)
    auth_token = r['access_token']
    expires_time = r['expires']
    db.update('delete from snstokens where auth_provider=?', provider)
    SNSTokens(auth_id=auth_id, auth_provider=provider, auth_name=name, auth_token=auth_token, expires_time=expires_time).insert()
    raise seeother('/manage/setting/snstokens')
开发者ID:michaelliao,项目名称:brighterpage,代码行数:20,代码来源:__init__.py

示例14: register

def register():
    if ctx.request.user:
        raise seeother('/')
    return dict()
开发者ID:Spacebody,项目名称:ProfStudSystem,代码行数:4,代码来源:urls.py

示例15: signout

def signout():
	ctx.response.delete_cookie(_COOKIE_NAME)
	raise seeother('/')
开发者ID:dasbindus,项目名称:my-python-webapp,代码行数:3,代码来源:urls.py


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