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

Python base.render函数代码示例

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

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



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

示例1: document

    def document(self):
        resp = request.environ.get('pylons.original_response')
        req = request.environ.get('pylons.original_request')
        c.came_from = url.current()
        if resp is None:
            return render("/error.mako")

        c.reason = req.environ.get('ututi.access_denied_reason', None)
        if resp.status_int in [403, 404]:
            self.form_result = {}
            self._search()
            c.came_from = url('/')
            if resp.status_int == 403:
                return render("/access_denied.mako")

            elif resp.status_int == 404:
                h.flash(_("Document at %(url)s was not found, but maybe you are interested in something else?") % {
                        'url': req.url.encode('ascii', 'ignore')})

                # if user is logged in, show search form, otherwise - login form
                try:
                    if session['login']:
                        return render('/search/index.mako')
                except KeyError:
                    return render('/login.mako')

        return render("/error.mako")
开发者ID:nous-consulting,项目名称:ututi,代码行数:27,代码来源:error.py


示例2: invite_fb

    def invite_fb(self, group):
        # Handle POST.
        invited = request.params.get('ids[]')
        if invited:
            ids = invited.split(',')
            for facebook_id in ids:
                group.create_pending_fb_invitation(int(facebook_id), c.user)
            make_facebook_invitations(ids, c.user, group.location)
            meta.Session.commit()
            h.flash(ungettext('Invited %(num)d friend.',
                              'Invited %(num)d friends.',
                              len(ids)) % dict(num=len(ids)))
            redirect(c.group.url(action='members'))

        # Render page.
        fb_user = facebook.get_user_from_cookie(request.cookies,
                         config['facebook.appid'], config['facebook.secret'])
        c.has_facebook = fb_user is not None
        if c.has_facebook:
            try:
                graph = facebook.GraphAPI(fb_user['access_token'])
                friends = graph.get_object("me/friends")
            except facebook.GraphAPIError:
                c.has_facebook = False
        if not c.has_facebook:
            # Ask to log on to facebook.
            return render('group/invite.mako')

        friend_ids = [f['id'] for f in friends['data']]
        friend_users = meta.Session.query(User).filter(
                            User.facebook_id.in_(friend_ids)).all()
        c.exclude_ids = ','.join(str(u.facebook_id) for u in friend_users
                                 if c.group.is_member(u))
        return render('group/invite.mako')
开发者ID:nous-consulting,项目名称:ututi,代码行数:34,代码来源:group.py


示例3: _send_news

    def _send_news(self, period, **kwargs):
        dtstart, dtend = self.range(**kwargs)

        recipient_to_events = {}
        for event in self._all_events(dtstart, dtend):
            recipients = self._recipients(event, period)
            for recipient in recipients:
                events = recipient_to_events.setdefault(recipient.id, [])
                events.append(event)
        for uid, events in recipient_to_events.items():
            user = User.get_byid(uid)
            events = [ev for ev in events
                      if (ev.user is None or
                          (ev.user.id != uid and
                           ev.context not in user.ignored_subjects
                           and not ev.isEmptyFile()))]

            # process moderation events
            events = [ev for ev in events
                      if not isinstance(ev, ModeratedPostCreated) or ev.context.is_admin(user)]

            if not events:
                continue

            sections = self._get_sections(events)
            subject = self._subject(sections, events)
            extra_vars = {'sections': sections,
                          'subject': subject}
            text = render('/emails/news_text.mako',
                          extra_vars=extra_vars)
            html = render('/emails/news_html.mako',
                          extra_vars=extra_vars)
            msg = EmailMessage(subject, text, html)
            log.info("Sent to <%s> to %s" % (subject,  user.fullname))
            user = user.send(msg)
开发者ID:nous-consulting,项目名称:ututi,代码行数:35,代码来源:news.py


示例4: members

 def members(self, group):
     c.group_menu_current_item = 'members'
     c.show_info = True
     self._set_up_member_info(group)
     if check_crowds(['admin', 'moderator'], context=group):
         return render('group/members_admin.mako')
     else:
         return render('group/members.mako')
开发者ID:nous-consulting,项目名称:ututi,代码行数:8,代码来源:group.py


示例5: teacher_confirmed_email

def teacher_confirmed_email(teacher, confirmed):
    """Send an email to a teacher once he has been confirmed."""
    if confirmed:
        text = render('/emails/teacher_confirmed.mako', extra_vars={'teacher': teacher, 'config':config})
    else:
        text = render('/emails/teacher_rejected.mako', extra_vars={'teacher': teacher, 'config':config})
    msg = EmailMessage(_('Your account has been confirmed!'), text, force=True)
    msg.send(teacher)
开发者ID:nous-consulting,项目名称:ututi,代码行数:8,代码来源:emails.py


示例6: group_confirmation_email

def group_confirmation_email(group, user, status):
    """Send an email to the user when his request to join a group is confirmed."""
    if status:
        #the request has been confirmed
        text = render('/emails/group_confirmation.mako', extra_vars={'group': group, 'user': user})
    else:
        text = render('/emails/group_confirmation_deny.mako', extra_vars={'group': group, 'user': user})

    msg = EmailMessage(_('Ututi group membership confirmation'), text, force=True)
    msg.send(user)
开发者ID:nous-consulting,项目名称:ututi,代码行数:10,代码来源:emails.py


示例7: home

 def home(self, group):
     if not c.user:
         abort(404);
     if check_crowds(["member", "admin"]):
         if request.params.get('do_not_watch'):
             group.wants_to_watch_subjects = False
             meta.Session.commit()
         self._set_home_variables(group)
         return render('group/home.mako')
     else:
         c.breadcrumbs = [{'title': group.title,
                           'link': url(controller='group', action='home', id=c.group.group_id)}]
         return render('group/home_public.mako')
开发者ID:nous-consulting,项目名称:ututi,代码行数:13,代码来源:group.py


示例8: subdepartment

    def subdepartment(self, location, subdepartment):
        if c.user:
            c.current_menu_item = 'feed'
            self.feed_filter = 'sub_department'
            self.sub_department = subdepartment
            c.notabs = True

            c.show_discussion_form = False

            self._set_wall_variables()
            return render('location/sub_department_feed.mako')
        else:
            c.current_menu_item = 'about'
            return render('location/subdepartment.mako')
开发者ID:nous-consulting,项目名称:ututi,代码行数:14,代码来源:location.py


示例9: index

    def index(self):
        c.file_limit = int(config.get('small_file_size', 1024**2))
        c.schools = meta.Session.query(LocationTag).filter(LocationTag.parent == None).order_by(LocationTag.title_short.asc()).all()
        c.subjects = meta.Session.query(Subject).filter_by(deleted_by=None).order_by(Subject.title.asc()).all()
        c.groups = meta.Session.query(Group).filter_by(deleted_by=None).order_by(Group.title.asc()).all()

        cache = int(config.get('cache.lifetime', 7*24*3600))

        if cache != 0:
            return render('sitemap/index.mako',
                          cache_key='sitemap',
                          cache_expire=cache,
                          cache_type='file')
        else:
            return render('sitemap/index.mako')
开发者ID:nous-consulting,项目名称:ututi,代码行数:15,代码来源:sitemap.py


示例10: moderate_post

 def moderate_post(self, group, thread):
     if not thread.in_moderation_queue:
         redirect(thread.url())
     c.thread = thread
     c.group_menu_current_item = 'mailinglist'
     c.messages = thread.posts
     return render('mailinglist/moderate_post.mako')
开发者ID:nous-consulting,项目名称:ututi,代码行数:7,代码来源:mailinglist.py


示例11: add

    def add(self, subject):
        c.breadcrumbs = [{'link': c.subject.url(),
                          'title': c.subject.title},
                         {'link': subject.url(controller='subjectpage', action='add'),
                          'title': _('New page')}]

        return render('page/add.mako')
开发者ID:nous-consulting,项目名称:ututi,代码行数:7,代码来源:subjectpage.py


示例12: register_teacher

    def register_teacher(self, location):
        # bounce existing users to different action
        if c.user is not None:
            redirect(location.url(action='register_teacher_existing'))

        if not hasattr(self, 'form_result'):
            return htmlfill.render(self._register_teacher_form())

        email = self.form_result['email']

        if User.get(email, location):
            h.flash(_('The email you entered is registered in Ututi. '
                      'Please login to proceed.'))
            destination = location.url(action='register_teacher_existing')
            redirect(url(controller='home', action='login', email=email,
                         came_from=destination))

        # lookup/create registration entry and send confirmation code to user
        registration = UserRegistration.create_or_update(location, email)
        registration.teacher = True
        meta.Session.commit()
        registration.send_confirmation_email()

        # show confirmation page
        c.email = email
        return render('registration/email_approval.mako')
开发者ID:nous-consulting,项目名称:ututi,代码行数:26,代码来源:location.py


示例13: home

 def home(self, subject):
     if c.user:
         blank_subject = not subject.pages and not subject.n_files(include_deleted=False)
         if not (subject.description or blank_subject) or subject in c.user.watched_subjects:
             redirect(subject.url(action='feed'))
     c.current_tab = 'info'
     return render('subject/info.mako')
开发者ID:nous-consulting,项目名称:ututi,代码行数:7,代码来源:subject.py


示例14: lookup

    def lookup(self):
        # save posted variables for future
        title = self.form_result['title']
        location = self.form_result['location']
        session['subject_title'] = title
        session['subject_location_id'] = location.id
        session.save()

        # lookup for subjects similar to the one
        # that is about to be created
        search_params = {}
        search_params['obj_type'] = 'subject'
        search_params['text'] = title
        search_params['tags'] = ', '.join(location.title_path)
        search_params['language'] = location.language

        query = search_query(**search_params)
        c.similar_subjects = paginate.Page(
            query,
            items_per_page = 30,
            item_count = search_query_count(query),
            **search_params)

        if c.similar_subjects:
            return render('subject/add_lookup.mako')
        else:
            # no similar subjects found
            return redirect(url(controller='subject', action='add_description'))
开发者ID:nous-consulting,项目名称:ututi,代码行数:28,代码来源:subject.py


示例15: index

    def index(self):
        if c.user is not None and self.form_result == {}:
            redirect(url(controller='profile', action='browse'))

        self._search()
        self._search_locations(c.text)
        return render('/search/index.mako')
开发者ID:nous-consulting,项目名称:ututi,代码行数:7,代码来源:search.py


示例16: send_registration_invitation

def send_registration_invitation(registration, inviter=None, message=None):
    text = render('/emails/registration_invitation.mako',
                  extra_vars={'registration': registration,
                              'inviter': inviter,
                              'message': message})
    msg = EmailMessage(_('Invitation to Ututi'), text)
    msg.send(registration.email)
开发者ID:nous-consulting,项目名称:ututi,代码行数:7,代码来源:emails.py


示例17: _send_ending_period_reminder

 def _send_ending_period_reminder(self, group):
     subject = _('The private space subscription for "%s" is about to expire') % group.title
     extra_vars = dict(group=group)
     text = render('/emails/group_space_ending.mako', extra_vars=extra_vars)
     msg = EmailMessage(subject, text)
     group.send(msg)
     group.ending_period_notification_sent = True
开发者ID:nous-consulting,项目名称:ututi,代码行数:7,代码来源:news.py


示例18: index

 def index(self, subject, page):
     if page not in subject.pages:
         abort(404)
     if page.isDeleted() and not check_crowds(['moderator']):
         abort(404)
     c.current_tab = 'pages'
     return render('page/view.mako')
开发者ID:nous-consulting,项目名称:ututi,代码行数:7,代码来源:subjectpage.py


示例19: administration

 def administration(self, group):
     c.messages = meta.Session.query(GroupMailingListMessage)\
         .filter_by(group_id=group.id, in_moderation_queue=True)\
         .order_by(desc(GroupMailingListMessage.sent)).all()
     c.group_menu_current_item = 'mailinglist'
     response.cache_expires(seconds=0)
     return render('mailinglist/administration.mako')
开发者ID:nous-consulting,项目名称:ututi,代码行数:7,代码来源:mailinglist.py


示例20: login

    def login(self):
        # Here below email get parameter may be used for convenience
        # i.e. when redirecting from sign-up form.
        # POST and GET params are accepted for external javascript logins
        # to work via JSONP (see _js_login above).

        username = request.params.get('username') or request.params.get('email')
        password = request.params.get('password')
        location = request.params.get('location')
        location = int(location) if location else None
        remember = bool(request.params.get('remember'))

        if 'js' in request.params:
            return self._js_login(username, password, location, remember)

        errors = None
        if username and password:
            # form was posted
            errors = self._try_sign_in(username, password, location, remember)
            if errors is None:
                redirect(c.came_from or url(controller='profile', action='home'))

        # show the form, possibly with errors.
        return htmlfill.render(render('login.mako'),
                               errors=errors,
                               error_formatters=u_error_formatters,
                               defaults={'username': username,
                                         'location': location,
                                         'came_from': c.came_from})
开发者ID:nous-consulting,项目名称:ututi,代码行数:29,代码来源:home.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python helpers.flash函数代码示例发布时间:2022-05-26
下一篇:
Python meta_util_six.get_funcname函数代码示例发布时间: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