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

Python util.render函数代码示例

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

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



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

示例1: post

    def post(self):
        name = self.request.get('name')
        #uid = TODO get User ID

        #create levelSet

        util.render(self, 'set/read.html', {'name': name})
开发者ID:jethrolarson,项目名称:pixeljs,代码行数:7,代码来源:LevelSet.py


示例2: recover_password_get

    def recover_password_get(self):
        if web.ctx.query == '':
            qs = dict()
        else:
            # XXX: http://bugs.python.org/issue8136
            qs = parse_qs(urllib.unquote(web.ctx.query[1:]).encode('latin-1').decode('utf-8'))

        if not (qs.has_key('id') and qs.has_key('key')):
            return util.render().error(error_message = _('INVALID_LINK'),
                    help_context = 'error')
        user_id = qs['id'][0]
        key = qs['key'][0]
        uid = user._get_uid_from_username(user_id)
        if uid < 0:
            return util.render().error(error_message = _('INVALID_USERNAME'),
                    help_context = 'error')
        if user.get_password_salt(uid) != key:
            return util.render().error(error_message = _('INVALID_PASSWORD_KEY'),
                    help_context = 'error')

        self.session_set(user_id)
        web.ctx.session.persistent = False
        user.update_last_login(uid, web.ctx.ip)
        new_pw = user.generate_random_password()
        user.update_password(uid, new_pw)
        return util.render().error(error_message = _('Your temporary password is "%s"(case-sensitive). Change password now.') % new_pw,
                error_class = _('Information'))
开发者ID:peremen,项目名称:noah3k,代码行数:27,代码来源:web_main.py


示例3: get

 def get(self, key):
     if not len(key):
         return util.error(self, 404, 'No level specified')
     lvl = db.get(db.Key(key))
     if not lvl:
         return util.error(self, 404, 'Level not found')
     util.render(self, 'level/read.html', {'level': lvl.getDict(), 'title': lvl.title})
开发者ID:jethrolarson,项目名称:pixeljs,代码行数:7,代码来源:Level.py


示例4: pp

 def pp(info):
     pos = info['pos']
     if pos == 'n':
         cases_ja = [latin1.cases_ja[case[0:3]] + case[3:6] for case in info['case'].split('/')]
         return util.render([pos, info['base'], info['case'], info['gender'], info['ja'], cases_ja])
     else:
         return util.render(info)
开发者ID:naoyat,项目名称:latin,代码行数:7,代码来源:read.py


示例5: create_board_post

    def create_board_post(self, board_name, board_id, current_uid = -1):
        board_info = board.get_board_info(board_id)
        if not acl.is_allowed('board', board_id, current_uid, 'create'):
            return util.render().error(error_message = _('NO_PERMISSION'), help_context='error')
        user_data = web.input()
        comment = 1 if user_data.has_key('commentable') else 0
        write_by_other = 1 if user_data.has_key('writable') else 0
        indexable = 1 if user_data.has_key('indexable') else 0
        show_avatar = 1 if user_data.has_key('show_avatar') else 0

        owner_uid = user._get_uid_from_username(user_data.owner)
        if owner_uid < 0:
            return util.render().error(error_message=_('NO_SUCH_USER_FOR_BOARD_ADMIN'), help_context='error')
        if user_data.name.strip() == '':
            return util.render().error(error_message = _('NO_NAME_SPECIFIED'), help_context='error')
        if board_name == '^root':
            new_path = posixpath.join('/', user_data.name)
        else:
            new_path = posixpath.join('/', board_name, user_data.name)
        if board._get_board_id_from_path(new_path) > 0:
            return util.render().error(error_message = _('BOARD_EXISTS'), help_context='error')

        settings = dict(path=new_path, board_owner = owner_uid,
                cover = user_data.information,
                description = user_data.description,
                type = int(user_data.type),
                guest_write = write_by_other,
                can_comment = comment,
                indexable = indexable, show_avatar = show_avatar,
                current_uid = current_uid)
        ret = board.create_board(board_id, settings)
        if ret[0] == False:
            return util.render().error(error_message = ret[1] ,help_context = 'error')
        raise web.seeother(util.link('%s') % (new_path))
开发者ID:peremen,项目名称:noah3k,代码行数:34,代码来源:web_board.py


示例6: lost_login_post

    def lost_login_post(self):
        data = web.input()
        recaptcha_url = 'http://www.google.com/recaptcha/api/verify'
        recaptcha_data = dict(challenge = data.recaptcha_challenge_field,
                response = data.recaptcha_response_field,
                remoteip = web.ctx.ip,
                privatekey = config.recaptcha_private_key)
        req = urllib2.Request(recaptcha_url, urllib.urlencode(recaptcha_data))
        response = urllib2.urlopen(req)
        page = response.read().split('\n')
        if page[0] == 'false':
            if page[1].strip() == 'incorrect-captcha-sol':
                return util.render().error(error_message = _('INCORRECT_CAPTCHA'), help_context='error')
            else:
                return util.render().error(error_message = _('CAPTCHA_ERROR'), help_context='error')
        found_users = user.get_user_from_email(data.email)
        if not found_users:
            return util.render().error(error_message = _('NO_SUCH_MAIL_ADDRESS'), help_context='error')
        salt_string = ''
        for u in found_users:
            salt = user.get_password_salt(u.uSerial)
            salt_string = salt_string + '* User %s: http://noah.kaist.ac.kr/+recover_password?id=%s&key=%s\n' % (u.uId, u.uId, salt)
        message_title = _('NOAH password recovery')
        message_body = _('''Dear NOAH user,

Some user on IP %s requested new password of your account(s). Following list contains your account(s). Click on the corresponding link for recovering password of account.

%s

If you did not requested password recovery, then please log in into your account. This link will not be vaild after logging into the account.''') % (web.ctx.ip, salt_string)
        mail.mail(data.email, message_title, message_body)
        return util.render().error(error_message = _('Message Sent. Please follow instructions on the message.'),
                error_class = _('Information'))
开发者ID:peremen,项目名称:noah3k,代码行数:33,代码来源:web_main.py


示例7: modify_post

    def modify_post(self, board_name, board_id, current_uid = -1):
        board_info = board.get_board_info(board_id)
        if not acl.is_allowed('board', board_id, current_uid, 'modify'):
            return util.render().error(error_message=_('NO_PERMISSION'), help_context='error')
        data = web.input()
        comment = 1 if data.has_key('commentable') else 0
        write_by_other = 1 if data.has_key('writable') else 0
        indexable = 1 if data.has_key('indexable') else 0
        show_avatar = 1 if data.has_key('show_avatar') else 0

        owner_uid = user._get_uid_from_username(web.input().owner)
        if owner_uid < 0:
            return util.render().error(error_message=_('NO_SUCH_USER_FOR_BOARD_ADMIN'), help_context='error')

        board_info = dict(path = data.path, name = data.name,
                owner = owner_uid, board_type = int(data.type),
                can_comment = comment, can_write_by_other = write_by_other,
                indexable = indexable, show_avatar = show_avatar,
                stylesheet = data.stylesheet,
                description = data.description,
                cover = data.information)
        result = board.board_edit(current_uid, board_id, board_info)
        if result[0] == False:
            return util.render().error(error_message = result[1], help_context='error')
        else:
            raise web.seeother(util.link('%s') % result[1])
开发者ID:peremen,项目名称:noah3k,代码行数:26,代码来源:web_board.py


示例8: modify_post

    def modify_post(self, current_uid = -1):
        user_id = current_uid
        usr = user.get_user(user_id)[1]

        data = web.input(profile_image = {})
        if data.newpass1 and not user.verify_password(user_id, data.oldpass):
            return util.render().error(error_message=_('INVALID_PASSWORD'), help_context='error')
        if data.newpass1 != data.newpass2:
            return util.render().error(error_message = _('PASSWORD_DO_NOT_MATCH'), help_context='error')
        if len(data.newpass1) > 0 and len(data.newpass1) < 6:
            return util.render().error(error_message = _('PASSWORD_TOO_SHORT'), help_context='error')
        if len(data.newpass1) == 0:
            password = data.oldpass
        else:
            password = data.newpass1
        nick = data.nick
        email = data.email
        homepage = data.homepage
        sig = data.sig
        introduction = data.introduction
        language = data.language
        theme = data.theme
        user_info = user.get_user(user_id)
        change_lang = False
        if language != user_info[1].language:
            change_lang = True
        profile_image = data.profile_image.value
        delete_profile_image = data.has_key('delete_profile_image')

        ret = user.modify_user(user_id, locals())
        if change_lang:
            web.ctx.session.lang = language
        raise web.seeother(util.link('/+u'))
开发者ID:peremen,项目名称:noah3k,代码行数:33,代码来源:web_user.py


示例9: callback

def callback(request):
    auth_user(request.cookies.get('auth'))
    if g.user:
        return util.redirect('/')

    oauth_client = oauth2.Client2(
        oauth_settings['client_id'],
        oauth_settings['client_secret'],
        oauth_settings['base_url']
        )

    code = request.GET.get('code')
    if not code:
        return util.render('error.pat', user=None,
                           error="no code")

    try:
        data = oauth_client.access_token(code, oauth_settings['redirect_url'])
    except Exception as e:
        return util.render('error.pat', user=None,
                           error="failed to get access token, try again")
    access_token = data.get('access_token')

    (headers, body) = oauth_client.request(
        'https://api.github.com/user',
        access_token=access_token,
        token_param='access_token'
        )

    error = 0
    try:
        if headers['status'] == '200':
            user = json.loads(body)
            username = user['login']
            email = user.get('email', '')
        else:
            error = 1
    except Exception as e:
        error = 1

    if error:
        return util.render('error.pat', user=None, error='bad login, try again')

    user = get_user_by_name(username)
    if not user:
        #create new user
        auth, msg = create_user_github(username, email)
        if not auth:
            return util.render('error.pat', user=None, error=msg)
    else:
        if 'g' in user['flags']:
            auth = user['auth']
        else:
            return util.render('error.pat', user=None, error='account exists :(')

    res = webob.exc.HTTPTemporaryRedirect(location='/')
    res.headers['Set-Cookie'] = 'auth=' + auth + \
        '; expires=Thu, 1 Aug 2030 20:00:00 UTC; path=/';
    return res
开发者ID:argolab,项目名称:lusernews,代码行数:59,代码来源:github.py


示例10: GET

 def GET(self, username, current_uid = -1):
     user_id = user._get_uid_from_username(username)
     if user_id < 0:
         raise web.notfound(util.render().error(error_message = _('NO_SUCH_USER'), help_context='error'))
     return util.render().myinfo(user = user.get_user(user_id)[1],
             user_id = user_id,
             title = _('User Information'), board_desc = _('User Information'),
             help_context='myinfo')
开发者ID:peremen,项目名称:noah3k,代码行数:8,代码来源:web_user.py


示例11: get

 def get(self):
     #get key
     ls = models.getUserLevelSet()
     self.redirect("/levelSet/" + str(ls.key()))
     return
     #old stuff
     levelSets = models.getUserLevelSets()
     util.render(self, 'user/read.html', {'levelSets': levelSets, 'user': models.getCurrentUser()})
开发者ID:jethrolarson,项目名称:pixeljs,代码行数:8,代码来源:User.py


示例12: caller

 def caller(self, board_name, action, article_id, method):
     board_id = board._get_board_id_from_path(board_name)
     if board_id < 0:
         raise web.notfound(util.render().error(error_message = _('INVALID_BOARD'), help_context='error'))
     try:
         return eval('self.%s_%s' % (action, method))(board_name, board_id, int(article_id))
     except AttributeError:
         raise web.notfound(util.render().error(error_message = _('INVALID_ACTION'), help_context='error'))
开发者ID:peremen,项目名称:noah3k,代码行数:8,代码来源:web_article.py


示例13: search_byname_view

def search_byname_view(request):

    error_message = None

    bank = request.user.get_profile().bank

    if request.POST:
        #name_terms = request.POST['namecontains']
        # TODO: I am a terrible person. 
        name_terms = request.POST['term1']
        if request.POST['term2'] != "":
            name_terms += " " + request.POST['search_type'].upper() + " " + \
                    request.POST['term2']
        if request.POST['term3'] != "":
            name_terms += " " + request.POST['search_type'].upper() + " " + \
                    request.POST['term3']
        if request.POST['term4'] != "":
            name_terms += " " + request.POST['search_type'].upper() + " " + \
                    request.POST['term4']

        logger.info(name_terms)

        if len(name_terms.strip()) < 1:
            error_message = "No search terms entered!"
        else:
            if " AND " in name_terms:
                # split on any AND's and strip any remaining whitespace
                name_contains = [a.strip() for a in name_terms.split(' AND ')]

                risks = BankRisk.objects.filter(bank=bank)
                for i in name_contains:
                    risks = risks.filter(
                            name__contains=i,
                    )
            else:

                # split on any OR's and strip any remaining whitespace
                name_contains = [a.strip() for a in name_terms.split(' OR ')]

                risks = []
                for i in name_contains:
                    risks.extend(BankRisk.objects.filter(
                            bank=bank,
                            name__contains=i,
                    ))

            # set the search results session var
            # request.session['search_results'] = risks
            return render('search_results.html',
                          { 'risks': risks,
                            'method': "by Name",
                            'search_again': "name", },
                          request)

    return render('search_byname.html',
                  { 'error_message': error_message }, 
                  request)
开发者ID:quasarj,项目名称:alpacaerm,代码行数:57,代码来源:views.py


示例14: newspage

def newspage(request, news_id):
    auth_user(request.cookies.get('auth'))
    news = get_news_by_id(news_id)
    if not news:
        return util.render('error.pat', user=g.user,
                           error="the news does not exist")

    hack_news(news)
    return util.render('news.pat', user=g.user, news=news)
开发者ID:argolab,项目名称:lusernews,代码行数:9,代码来源:app.py


示例15: documentation

def documentation(request, path='documentation'):
    if '.' in path[-5:]:
        template = 'documentation/%s' % path
    else:
        template = 'documentation/%s.html' % path
    try:
        return render(template, request, context_dict={'navigation_pos': 'documentation'})
    except TemplateDoesNotExist:
        return render('coming-soon.html', request, context_dict={'navigation_pos': 'documentation'})
开发者ID:LogicalSpark,项目名称:indextank-service,代码行数:9,代码来源:views.py


示例16: search_get

    def search_get(self, board_name, board_id):
        board_info = board.get_board_info(board_id)
        if web.ctx.query == '':
            qs = dict()
        else:
            # XXX: http://bugs.python.org/issue8136
            qs = parse_qs(urllib.unquote(web.ctx.query[1:]).encode('latin-1').decode('utf-8'))

        if not qs.has_key('q'):
            return util.render().error(error_message = _('NO_KEYWORD_SPECIFIED'),
                    help_context = 'error')
        keyword = qs['q'][0]
        if qs.has_key('size'):
            page_size = int(qs['size'][0])
        else:
            page_size = config.page_size
        if qs.has_key('page'):
            page_no = int(qs['page'][0])
        else:
            page_no = 1
        author = False
        title = True
        body = True
        if qs.has_key('author'):
            author = True
            title = False
            body = False
        if qs.has_key('title'):
            title = True
            body = False
        if qs.has_key('body'):
            body = True
        ret = article.search_article(board_id, keyword, page_size, page_no,
                author, title, body)
        search_qs = "/+search?"
        if author:
            search_qs += "author=1&"
        if title:
            search_qs += "title=1&"
        if body:
            search_qs += "body=1&"
        if keyword:
            search_qs += "q=%s" % urllib.quote(keyword.encode('utf-8'))
        if ret[0]:
            return util.render().board(lang="ko",
                title = board_info.bName,
                board_path = board_info.bName[1:],
                board_desc = _('Search Results'),
                stylesheet = board_info.stylesheet,
                articles=ret[2], marked_articles = [],
                total_page = ret[1], page = page_no, feed = False,
                help_context = 'view_board', indent = False,
                author_checked = author, title_checked = title,
                body_checked = body, search_keyword = keyword,
                search_qs = search_qs)
        else:
            return util.render().error(error_message = ret[1], help_context='error')
开发者ID:peremen,项目名称:noah3k,代码行数:57,代码来源:web_board.py


示例17: delete_post

 def delete_post(self, board_name, board_id, article_id, current_uid = -1):
     if not acl.is_allowed('article', article_id, current_uid, 'delete'):
         return util.render().error(error_message = _('NO_PERMISSION'), help_context='error')
     ret = article.delete_article(current_uid, article_id)
     attachment.remove_all_attachment(article_id)
     if ret[0] == True:
         raise web.seeother(util.link('/%s') % (board_name))
     else:
         return util.render().error(error_message = ret[1], help_context='error')
开发者ID:peremen,项目名称:noah3k,代码行数:9,代码来源:web_article.py


示例18: delete_get

 def delete_get(self, board_name, board_id, article_id, current_uid = -1):
     if not acl.is_allowed('article', article_id, current_uid, 'delete'):
         return util.render().error(error_message = _('NO_PERMISSION'), help_context='error')
     default_referer = os.path.join(util.link('/'), board_name, '+read', str(article_id))
     action=os.path.join(util.link('/'), board_name, '+delete', str(article_id))
     return util.render().question(
             question=_('Do you want to delete the article?'),
             board_path = board_name, 
             board_desc = _('Confirmation'), title=_('Confirmation'),
             action = action,
             referer=web.ctx.env.get('HTTP_REFERER', default_referer))
开发者ID:peremen,项目名称:noah3k,代码行数:11,代码来源:web_article.py


示例19: GET

    def GET(self, board_name):
        if board_name == '*' or board_name == '^root':
            v = board_actions()
            return v.subboard_list_get()

        board_id = board._get_board_id_from_path(board_name)
        if board_id < 0:
            #try to find regex match
            board_id = board._get_board_id_from_regex_path(board_name)
            if board_id < 0:
                raise web.notfound(util.render().error(lang='ko', error_message=_('INVALID_BOARD'), help_context='error'))
            else:
                path = board._get_path_from_board_id(board_id)
                raise web.seeother(util.link(path))

        board_info = board.get_board_info(board_id)
        if board_info.bType == 0: # 디렉터리
            v = board_actions()
            return v.subboard_list_get(board_name, board_id)
        elif board_info.bType == 2: # 넘겨주기
            board_id = board._get_board_id_from_path(board_info.bDescription)
            if board_id < 0 or board_info.bDescription.strip() == '':
                raise web.notfound(util.render().error(lang='ko', error_message=_('INVALID_ALIAS'), help_context='error'))
            else:
                raise web.seeother(util.link(board_info.bDescription))

        #processing new_article
        if web.ctx.session.has_key('uid'):
            uid = web.ctx.session.uid
            user.update_unreaded_articles_board(uid, board_id)

        qs = web.ctx.query
        if len(qs) > 0:
            qs = qs[1:]
            qs = parse_qs(qs)


        t = article._get_total_page_count(board_id, config.page_size)
        if qs:
            page = int(qs['page'][0])
        else:
            page = t

        a = article.get_article_list(board_id, config.page_size, page)
        m = article.get_marked_article(board_id)

        return util.render().board(lang="ko",
            title = board_info.bName,
            board_path = board_info.bName[1:],
            board_desc = board_info.bDescription,
            stylesheet = board_info.stylesheet,
            articles=a, marked_articles = m,
            total_page = t, page = page, feed = True,
            help_context = 'board')
开发者ID:peremen,项目名称:noah3k,代码行数:54,代码来源:webpage.py


示例20: write_get

 def write_get(self, board_name, board_id, current_uid = -1):
     board_info = board.get_board_info(board_id)
     if board_info.bType != 1:
         raise web.notfound(util.render().error(error_message = _('CANNOT_WRITE_ON_THIS_BOARD'), help_context='error'))
     board_desc = board_info.bDescription
     user_info = user.get_user(current_uid)[1]
     return util.render().article_edit(
             title = _('Write article - %s') % (board_name),
             action='write', action_name = _('Write article'),
             board_path = board_name, board_desc = board_desc, lang="ko",
             stylesheet = board_info.stylesheet,
             body = '\n\n\n%s' % user_info['uSig'], help_context='article_edit')
开发者ID:peremen,项目名称:noah3k,代码行数:12,代码来源:web_board.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python util.render_template函数代码示例发布时间:2022-05-26
下一篇:
Python util.remove_unicode_literals函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap