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


Python themes.render_template函数代码示例

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


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

示例1: do_modify

 def do_modify(self):
     method = request.method
     if method in ['GET', 'HEAD']:
         if isinstance(self.content, NonExistentContent):
             return render_template('modify_select_contenttype.html',
                                    fqname=self.fqname,
                                    item_name=self.name,
                                    itemtype=self.itemtype,
                                    group_names=content_registry.group_names,
                                    groups=content_registry.groups,
                                   )
         item = self
         if isinstance(self.rev, DummyRev):
             template_name = request.values.get('template')
             if template_name is None:
                 return self._do_modify_show_templates()
             elif template_name:
                 item = Item.create(template_name)
         form = self.ModifyForm.from_item(item)
     elif method == 'POST':
         # XXX workaround for *Draw items
         if isinstance(self.content, Draw):
             try:
                 self.content.handle_post()
             except AccessDenied:
                 abort(403)
             else:
                 # *Draw Applets POSTs more than once, redirecting would
                 # break them
                 return "OK"
         form = self.ModifyForm.from_request(request)
         meta, data, contenttype_guessed, comment = form._dump(self)
         state = dict(fqname=self.fqname, itemid=meta.get(ITEMID), meta=meta)
         if form.validate(state):
             contenttype_qs = request.values.get('contenttype')
             try:
                 self.modify(meta, data, comment, contenttype_guessed, **{CONTENTTYPE: contenttype_qs})
             except AccessDenied:
                 abort(403)
             else:
                 return redirect(url_for_item(**self.fqname.split))
     help = CONTENTTYPES_HELP_DOCS[self.contenttype]
     if isinstance(help, tuple):
         help = self.doc_link(*help)
     return render_template(self.modify_template,
                            fqname=self.fqname,
                            item_name=self.name,
                            item=self,
                            rows_meta=str(ROWS_META), cols=str(COLS),
                            form=form,
                            search_form=None,
                            help=help,
                            meta=item._meta_info(),
                           )
开发者ID:yask123,项目名称:moinmoin,代码行数:54,代码来源:__init__.py

示例2: do_modify

    def do_modify(self):
        is_new = isinstance(self.content, NonExistentContent)
        closed = self.meta.get('closed')

        Form = TicketSubmitForm if is_new else TicketUpdateForm

        if request.method in ['GET', 'HEAD']:
            form = Form.from_item(self)
        elif request.method == 'POST':
            form = Form.from_request(request)
            if form.validate():
                meta, data = form._dump(self)
                try:
                    self.modify(meta, data)
                except AccessDenied:
                    abort(403)
                else:
                    return redirect(url_for('.show_item', item_name=self.name))

        # XXX When creating new item, suppress the "foo doesn't exist. Create it?" dummy content
        data_rendered = None if is_new else Markup(self.content._render_data())

        return render_template(self.submit_template if is_new else self.modify_template,
                               is_new=is_new,
                               closed=closed,
                               item_name=self.name,
                               data_rendered=data_rendered,
                               form=form,
                              )
开发者ID:rciorba,项目名称:moin-2.0-mirror,代码行数:29,代码来源:ticket.py

示例3: _select_itemtype

 def _select_itemtype(self):
     return render_template('modify_select_itemtype.html',
                            item=self,
                            item_name=self.name,
                            fqname=self.fqname,
                            itemtypes=item_registry.shown_entries,
                           )
开发者ID:gitpraetorianlabs,项目名称:moin-2.0,代码行数:7,代码来源:__init__.py

示例4: wikiconfighelp

def wikiconfighelp():
    def format_default(default):
        if isinstance(default, defaultconfig.DefaultExpression):
            default_txt = default.text
        else:
            default_txt = repr(default)
            if len(default_txt) > 30:
                default_txt = '...'
        return default_txt

    groups = []
    for groupname in defaultconfig.options:
        heading, desc, opts = defaultconfig.options[groupname]
        opts = sorted([(groupname + '_' + name, format_default(default), description)
                       for name, default, description in opts])
        groups.append((heading, desc, opts))
    for groupname in defaultconfig.options_no_group_name:
        heading, desc, opts = defaultconfig.options_no_group_name[groupname]
        opts = sorted([(name, format_default(default), description)
                       for name, default, description in opts])
        groups.append((heading, desc, opts))
    groups.sort()
    return render_template('admin/wikiconfighelp.html',
                           title_name=_(u"Wiki Configuration Help"),
                           groups=groups)
开发者ID:pombredanne,项目名称:moin2,代码行数:25,代码来源:views.py

示例5: _render_data

    def _render_data(self):
        try:
            from MoinMoin.converter import default_registry as reg

            # TODO: Real output format
            doc = self.internal_representation()
            doc = self._expand_document(doc)
            flaskg.clock.start("conv_dom_html")
            html_conv = reg.get(type_moin_document, Type("application/x-xhtml-moin-page"))
            doc = html_conv(doc)
            flaskg.clock.stop("conv_dom_html")
            rendered_data = conv_serialize(doc, {html.namespace: ""})
        except Exception:
            # we really want to make sure that invalid data or a malfunctioning
            # converter does not crash the item view (otherwise a user might
            # not be able to fix it from the UI).
            import time
            import uuid

            error_id = uuid.uuid4()
            logging.exception("An exception happened in _render_data (error_id = %s ):" % error_id)
            rendered_data = render_template(
                "crash.html", server_time=time.strftime("%Y-%m-%d %H:%M:%S %Z"), url=request.url, error_id=error_id
            )
        return rendered_data
开发者ID:rciorba,项目名称:moin-2.0-mirror,代码行数:25,代码来源:content.py

示例6: sitemap

def sitemap():
    """
    Google (and others) XML sitemap
    """
    def format_timestamp(t):
        tm = time.gmtime(t)
        return time.strftime("%Y-%m-%dT%H:%M:%S+00:00", tm)

    sitemap = []
    for rev in flaskg.storage.documents(wikiname=app.cfg.interwikiname):
        fqnames = rev.fqnames
        mtime = rev.meta[MTIME]
        # these are the content items:
        changefreq = "daily"
        priority = "0.5"
        sitemap += [((fqname, format_timestamp(mtime), changefreq, priority)) for fqname in fqnames]
    # add entries for root urls
    root_mapping = [(namespace, app.cfg.root_mapping.get(namespace, app.cfg.default_root)) for namespace, _ in app.cfg.namespace_mapping]
    query = Or([And([Term(NAME_EXACT, root), Term(NAMESPACE, namespace)]) for namespace, root in root_mapping])
    for rev in flaskg.storage.search(q=query):
        mtime = rev.meta[MTIME]
        sitemap.append((rev.meta[NAMESPACE], format_timestamp(mtime), "hourly", "1.0"))
    sitemap.sort()
    content = render_template('misc/sitemap.xml', sitemap=sitemap)
    return Response(content, mimetype='text/xml')
开发者ID:rciorba,项目名称:moin-2.0-mirror,代码行数:25,代码来源:views.py

示例7: item_acl_report

def item_acl_report():
    """
    Return a list of all items in the wiki along with the ACL Meta-data
    """
    all_items = flaskg.storage.documents(wikiname=app.cfg.interwikiname)
    items_acls = []
    for item in all_items:
        item_namespace = item.meta.get(NAMESPACE)
        item_id = item.meta.get(ITEMID)
        item_name = item.meta.get(NAME)
        item_acl = item.meta.get(ACL)
        acl_default = item_acl is None
        fqname = CompositeName(item_namespace, u'itemid', item_id)
        if acl_default:
            for namespace, acl_config in app.cfg.acl_mapping:
                if item_namespace == namespace[:-1]:
                    item_acl = acl_config['default']
        items_acls.append({'name': item_name,
                           'itemid': item_id,
                           'fqname': fqname,
                           'acl': item_acl,
                           'acl_default': acl_default})
    return render_template('admin/item_acl_report.html',
                           title_name=_('Item ACL Report'),
                           items_acls=items_acls)
开发者ID:YelaSeamless,项目名称:moin-2.0,代码行数:25,代码来源:views.py

示例8: sitemap

def sitemap():
    """
    Google (and others) XML sitemap
    """
    def format_timestamp(t):
        tm = time.gmtime(t)
        return time.strftime("%Y-%m-%dT%H:%M:%S+00:00", tm)

    sitemap = []
    for rev in flaskg.storage.documents(wikiname=app.cfg.interwikiname):
        name = rev.meta[NAME]
        mtime = rev.meta[MTIME]
        if False: # was: wikiutil.isSystemItem(name)   XXX add back later, when we have that in the index
            if not SITEMAP_HAS_SYSTEM_ITEMS:
                continue
            # system items are rather boring
            changefreq = "yearly"
            priority = "0.1"
        else:
            # these are the content items:
            changefreq = "daily"
            priority = "0.5"
        sitemap.append((name, format_timestamp(mtime), changefreq, priority))
    # add an entry for root url
    root_item = app.cfg.item_root
    revs = list(flaskg.storage.documents(wikiname=app.cfg.interwikiname, name=root_item))
    if revs:
        mtime = revs[0].meta[MTIME]
        sitemap.append((u'', format_timestamp(mtime), "hourly", "1.0"))
    sitemap.sort()
    content = render_template('misc/sitemap.xml', sitemap=sitemap)
    return Response(content, mimetype='text/xml')
开发者ID:pombredanne,项目名称:moin2,代码行数:32,代码来源:views.py

示例9: _render_data_diff_atom

 def _render_data_diff_atom(self, oldrev, newrev):
     if PIL is None:
         # no PIL, we can't do anything, we just call the base class method
         return super(TransformableBitmapImage, self)._render_data_diff_atom(oldrev, newrev)
     url = url_for('frontend.diffraw', _external=True, item_name=self.name, rev1=oldrev.revid, rev2=newrev.revid)
     return render_template('atom.html',
                            oldrev=oldrev, newrev=newrev, get='binary',
                            content=Markup(u'<img src="{0}" />'.format(escape(url))))
开发者ID:YelaSeamless,项目名称:moin-2.0,代码行数:8,代码来源:content.py

示例10: trash

def trash(namespace):
    """
    Returns the trashed items.
    """
    trash = _trashed(namespace)
    return render_template('admin/trash.html',
                           headline=_(u'Trashed Items'),
                           title_name=_(u'Trashed Items'),
                           results=trash)
开发者ID:YelaSeamless,项目名称:moin-2.0,代码行数:9,代码来源:views.py

示例11: do_show

 def do_show(self, revid):
     # First, check if the current user has the required privileges
     if flaskg.user.may.create(self.name):
         content = self._select_itemtype()
     else:
         content = render_template('show_nonexistent.html',
                                   item_name=self.name,
                                   fqname=self.fqname,
                                  )
     return Response(content, 404)
开发者ID:gitpraetorianlabs,项目名称:moin-2.0,代码行数:10,代码来源:__init__.py

示例12: interwikihelp

def interwikihelp():
    """display a table with list of known interwiki names / urls"""
    headings = [_('InterWiki name'),
                _('URL'),
               ]
    rows = sorted(app.cfg.interwiki_map.items())
    return render_template('admin/interwikihelp.html',
                           title_name=_(u"Interwiki Help"),
                           headings=headings,
                           rows=rows)
开发者ID:pombredanne,项目名称:moin2,代码行数:10,代码来源:views.py

示例13: _render_data_diff_html

    def _render_data_diff_html(self, oldrev, newrev, template):
        """ Render HTML formatted meta and content diff of 2 revisions

        :param oldrev: old revision object
        :param newrev: new revision object
        :param template: name of the template to be rendered
        :return: HTML data with meta and content diff
        """
        diffs = self._get_data_diff_html(oldrev.data, newrev.data)
        return render_template(template, item_name=self.name, oldrev=oldrev, newrev=newrev, diffs=diffs)
开发者ID:rciorba,项目名称:moin-2.0-mirror,代码行数:10,代码来源:content.py

示例14: urls_names

def urls_names():
    """
    List of all item URLs and names, e.g. for sisteritems.

    This view generates a list of item URLs and item names, so that other wikis
    can implement SisterWiki functionality easily.
    See: http://usemod.com/cgi-bin/mb.pl?SisterSitesImplementationGuide
    """
    # XXX we currently also get deleted items, fix this
    item_names = sorted([rev.meta[NAME] for rev in flaskg.storage.documents(wikiname=app.cfg.interwikiname)])
    content = render_template('misc/urls_names.txt', item_names=item_names)
    return Response(content, mimetype='text/plain')
开发者ID:pombredanne,项目名称:moin2,代码行数:12,代码来源:views.py

示例15: itemsize

def itemsize():
    """display a table with item sizes"""
    headings = [_('Size'),
                _('Item name'),
               ]
    rows = [(rev.meta[SIZE], rev.meta[NAME])
            for rev in flaskg.storage.documents(wikiname=app.cfg.interwikiname)]
    rows = sorted(rows, reverse=True)
    return render_template('admin/itemsize.html',
                           title_name=_(u"Item Size"),
                           headings=headings,
                           rows=rows)
开发者ID:pombredanne,项目名称:moin2,代码行数:12,代码来源:views.py


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