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


Python render.render函数代码示例

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


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

示例1: get

 def get(self):
     rdic = {}
     source = self.request.get('from', None)
     message = ''
     if source:
         session = Session(self)
         message = session.get('message','')
         session.delete('message')
     rdic['message'] = message
     comments = memcache.get('disqus$comments')
     ua = self.request.headers.get('User-Agent', 'bot')
     path = get_path(ua, 'dashboard.html')
     rdic['notes'] = dbs.Note.getten()
     if comments is not None:
         rdic['comments'] = comments
         return self.response.out.write(render(path,rdic))
     disqus_key = dbs.Vigo.get('disqus_key')
     disqus_forumid = dbs.Vigo.get('disqus_forumid')
     mydisqus = Disqus(disqus_key)
     mydisqus.get_forum_posts_rpc(disqus_forumid)
     result = mydisqus.get_forum_posts_result()
     comments = mydisqus.parse_data(result)
     memcache.set('god$comments', comments, 10800) # 3 hours
     rdic['comments'] = comments
     return self.response.out.write(render(path,rdic))
开发者ID:Quasimo,项目名称:Vealous,代码行数:25,代码来源:main.py

示例2: get

 def get(self):
     rdic = {}
     rdic['navs'] = get_navs()
     p = self.request.get('p',1)
     keys = dbs.Article.show_keys()
     mvdata = dbs.Article.get_page(keys, p)
     if mvdata['page'] > mvdata['page_num']:
         path = get_path(self.is_mobile, '404.html')
         self.response.set_status(404)
         html = render(path, rdic)
         return self.response.out.write(html)
     rdic['mvdata'] = mvdata
     path = get_path(self.is_mobile, 'archive.html')
     self.response.out.write(render(path,rdic))
开发者ID:lepture,项目名称:Vealous,代码行数:14,代码来源:blog.py

示例3: get

 def get(self, slug):
     ua = self.request.headers.get('User-Agent', 'bot')
     rdic = {}
     data = dbs.Note.get(slug)
     if not data:
         logging.info('404 , visite note ' + str(slug))
         path = get_path(ua, '404.html')
         self.response.set_status(404)
         html = render(path, rdic)
         return self.response.out.write(html)
     rdic['navs'] = dbs.Melody.get_all('nav')
     rdic['data'] = data
     path = get_path(ua, 'note.html')
     html = render(path, rdic)
     self.response.out.write(html)
开发者ID:Quasimo,项目名称:Vealous,代码行数:15,代码来源:blog.py

示例4: post

 def post(self):
     rdic = {}
     key = self.request.get('key', None)
     if not key:
         return self.redirect('/god/article')
     data = db.get(key)
     if not data:
         return self.redirect('/god/article')
     title = self.request.get('title', None)
     slug = self.request.get('slug', None)
     text = self.request.get('text', None)
     draft = self.request.get('draft', None)
     keyword = self.request.get('keyword', None)
     if draft:
         draft = True
     else:
         draft = False
     if title and slug:
         dbs.Article.update(data, title, slug, text, draft, keyword)
         session = Session(self)
         session['message'] = 'Article <a href="/god/article/edit?key=%s">%s</a> has been modified' % (data.key(), data.title)
         return self.redirect('/god/article?from=edit')
     rdic['data'] = data
     message = 'Please fill the required fields'
     rdic['message'] = message
     ua = self.request.headers.get('User-Agent', 'bot')
     path = get_path(ua, 'edit_article.html')
     return self.response.out.write(render(path,rdic))
开发者ID:Quasimo,项目名称:Vealous,代码行数:28,代码来源:main.py

示例5: get

 def get(self):
     source = self.request.get('from', None)
     message = ''
     if source:
         message = self.session.get('message','')
         self.session.delete('message')
     rdic = {}
     action = self.request.get('action', 'none').lower()
     key = self.request.get('key', 'none')
     status = self.request.get('draft', '2')
     if 'draft' == action or 'post' == action:
         data = db.get(key)
         if data and 'draft' == action:
             data.sw_status(data)
         elif data and 'post' == action:
             data.sw_status(data, False)
         else:
             self.session['message'] = "Can't find the article"
         return self.redirect('/god/article?from='+action)
     if 'filter' == action:
         data = self.get_filter(status)
     elif 'find' == action:
         data = self.get_find(key)
         if data:
             return self.redirect('/god/article/edit?key=%s' % data.key())
         message = "Not find the article"
         data = dbs.Article.gql('ORDER BY created DESC')
     else:
         data = dbs.Article.gql('ORDER BY created DESC')
     rdic['message'] = message
     p = self.request.get('p',1)
     rdic['mvdata'] = Paginator(data, count, p)
     path = get_tpl('article.html')
     return self.response.out.write(render(path,rdic))
开发者ID:jsy2046,项目名称:Vealous,代码行数:34,代码来源:main.py

示例6: post

 def post(self):
     rdic = {}
     key = self.request.get('key', None)
     p = self.request.get('p', 1)
     to = '/god/article?p=%s' % p
     if not key:
         return self.redirect(to)
     data = dbs.get_by_key(key)
     if not data:
         return self.redirect(to)
     title = self.request.get('title', None)
     slug = self.request.get('slug', None)
     text = self.request.get('text', None)
     draft = self.request.get('draft', None)
     keyword = self.request.get('keyword', None)
     if draft:
         draft = True
     else:
         draft = False
     if title and slug:
         data.update(title, slug, text, draft, keyword)
         self.session['message'] = 'Article <a href="/god/article/edit?key=%s">%s</a> has been modified' % (data.key(), data.title)
         if not draft:
             taskqueue.add(url='/god/task/ping', method="GET")
         return self.redirect(to + ';from=edit')
     rdic['data'] = data
     message = 'Please fill the required fields'
     rdic['message'] = message
     path = get_tpl('edit_article.html')
     return self.response.out.write(render(path,rdic))
开发者ID:lepture,项目名称:Vealous,代码行数:30,代码来源:main.py

示例7: get

 def get(self):
     path = get_tpl('twitter_user.html')
     rdic = {}
     source = self.request.get('from', None)
     message = ''
     if source:
         message = self.session.get('message','')
         self.session.delete('message')
     rdic['message'] = message
     qs = dbs.Vigo.get('oauth_twitter')
     if not qs:
         return self.redirect('/god/twitter/login')
     api = Twitter().set_qs_api(qs)
     statuses = memcache.get('twitter$home')
     if statuses is None:
         statuses = api.GetFriendsTimeline(count=30, retweets=True)
         for status in statuses:
             status.datetime = datetime.datetime.strptime(status.created_at, '%a %b %d %H:%M:%S +0000 %Y')
         memcache.set('twitter$home', statuses, 240)
     rdic['statuses'] = statuses
     username = dbs.Vigo.get('twitter')
     profile = memcache.get('twitter$profile$' + username)
     if profile is None:
         profile = api.GetUser(username)
         memcache.set('twitter$profile$'+username, profile, 86400)
     rdic['profile'] = profile
     rdic['username'] = username
     return self.response.out.write(render(path, rdic))
开发者ID:jsy2046,项目名称:Vealous,代码行数:28,代码来源:twitter.py

示例8: get

 def get(self):
     ua = self.request.headers.get('User-Agent', 'bot')
     path = get_path(ua, 'douban_dashboard.html')
     rdic = {}
     source = self.request.get('from', None)
     message = ''
     if source:
         session = Session(self)
         message = session.get('message','')
         session.delete('message')
     rdic['message'] = message
     qs = dbs.Vigo.get('oauth_douban')
     if not qs:
         return self.redirect('/god/douban/login')
     api = pydouban.Api()
     api.set_qs_oauth(config.douban_key, config.douban_secret, qs)
     profile = memcache.get('douban/profile')
     if profile is None:
         profile = api.get_profile()
         memcache.set('douban/profile', profile, day)
     rdic['profile'] = profile
     miniblogs = memcache.get('douban/miniblogs')
     if miniblogs is None:
         miniblogs = api.get_contacts_miniblog()
         for i in range(len(miniblogs.entry)):
             miniblogs.entry[i].published.t = datetime.datetime.strptime(
                 miniblogs.entry[i].published.t, '%Y-%m-%dT%H:%M:%S+08:00')
             miniblogs.entry[i].published.t -= datetime.timedelta(hours=8)
         memcache.set('douban/miniblogs', miniblogs, 240)
     rdic['miniblogs'] = miniblogs
     return self.response.out.write(render(path, rdic))
开发者ID:Quasimo,项目名称:Vealous,代码行数:31,代码来源:douban.py

示例9: post

 def post(self):
     rdic = {}
     key = self.request.get("key", None)
     if not key:
         return self.redirect("/god/melody")
     data = dbs.get_by_key(key)
     if not data:
         return self.redirect("/god/melody")
     label = self.request.get("label", None)
     title = self.request.get("title", None)
     url = self.request.get("url", None)
     prior = self.request.get("prior", 0)
     text = self.request.get("text", None)
     ext = self.request.get("ext", None)
     if title and label:
         try:
             prior = int(prior)
         except:
             prior = 0
         data.update(title, url, label, prior, ext, text)
         self.session["message"] = '%s <a href="/god/melody/edit?key=%s">%s</a> has been modified' % (
             data.label.upper(),
             data.key(),
             data.title,
         )
         return self.redirect("/god/melody?from=edit")
     rdic["data"] = data
     message = "Please fill the required fields"
     rdic["message"] = message
     path = get_tpl("edit_melody.html")
     return self.response.out.write(render(path, rdic))
开发者ID:wangjun,项目名称:Vealous,代码行数:31,代码来源:main.py

示例10: get

 def get(self, username):
     rdic = {}
     rdic['navs'] = get_navs()
     rdic['links'] = dbs.Melody.get_all('link')
     rdic['tweets'] = self.tweets(username)
     path = get_path(self.request, 'utils_twitter.html')
     self.response.out.write(render(path,rdic))
开发者ID:lepture,项目名称:Vealous,代码行数:7,代码来源:utils.py

示例11: post

    def post(self, eventid):
        # We use locals() which confuses pylint.
        # pylint: disable-msg=W0612
        ####################################################
        event = models.Event.get_by_id(long(eventid))
        if not event:
            self.redirect('/')
        current_user = users.get_current_user()
        if not current_user:
            self.redirect('/')
            return
        ####################################################

        response, guests = event_lists.get_event_responses(event, current_user)
        
        # Check if the person is trying to add friends
        try:
            extra_guests = range(
                0, int(self.request.get('friends', '0'))-len(guests))
        except ValueError:
            extra_guests = []

        if extra_guests:
            self.response.out.write(render(
                    'templates/response-friends.html', locals()))
            return
    
        # Remove the current information
        if response is not None:
            response.delete()
        for guest in guests:
            guest.delete()

        response = models.Response(event=event, gcreated_by = current_user,
                guest=False)
        response.attending = self.request.get('attending').lower() != 'no'
        response.put()

        logging.info('Response %s created by user %s (email: %s fedid: %s)',
                response.key(), current_user.nickname(), current_user.email(),
                current_user.federated_identity() )

        guest_names = self.request.get_all('guest_name')
        guest_emails = self.request.get_all('guest_email')
        assert len(guest_names) == len(guest_emails)

        for name, email in zip(guest_names, guest_emails):
            name, email = name.strip(), email.strip()
            if not name or not email:
                continue

            response = models.Response(event=event, guest=True,
                    gcreated_by = current_user)
            response.attending = True
            response.guest_name = name
            response.guest_email = email
            response.put()

        self.redirect('/event/%s/response/show' % event.key().id())
开发者ID:jamezpolley,项目名称:slug,代码行数:59,代码来源:response.py

示例12: get

 def get(self):
     rdic = {}
     rdic['navs'] = get_navs()
     p = self.request.get('p',1)
     keys = dbs.Article.show_keys()
     rdic['mvdata'] = dbs.Article.get_page(keys, p)
     path = get_path(self.is_mobile, 'archive.html')
     self.response.out.write(render(path,rdic))
开发者ID:wangjun,项目名称:Vealous,代码行数:8,代码来源:blog.py

示例13: get

 def get(self):
     rdic = {}
     rdic['navs'] = get_navs()
     p = self.request.get('p',1)
     data = dbs.Article.get_archive()
     rdic['mvdata'] = Paginator(data, 10, p)
     path = get_path(self.request, 'archive.html')
     self.response.out.write(render(path,rdic))
开发者ID:jsy2046,项目名称:Vealous,代码行数:8,代码来源:blog.py

示例14: get

 def get(self):
     auth = self.session.get("auth", 0)
     gauth = users.is_current_user_admin()
     if 1 == auth or gauth:
         self.redirect("/god")
     rdic = {}
     path = get_path(self.request, "login.html")
     rdic["gurl"] = users.create_login_url(self.request.url)
     return self.response.out.write(render(path, rdic))
开发者ID:wangjun,项目名称:Vealous,代码行数:9,代码来源:main.py

示例15: get

 def get(self):
     auth = self.session.get('auth',0)
     gauth = users.is_current_user_admin()
     if 1 == auth or gauth:
         self.redirect('/god')
     rdic = {}
     path = get_path(self.request, 'login.html')
     rdic['gurl'] = users.create_login_url(self.request.url)
     return self.response.out.write(render(path,rdic))
开发者ID:lepture,项目名称:Vealous,代码行数:9,代码来源:main.py


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