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

Python resource.get_resource_description函数代码示例

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

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



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

示例1: expand_macro

    def expand_macro(self, formatter, name, content):
        env = formatter.env
        req = formatter.req
        if not 'VOTE_VIEW' in req.perm:
            return
        # Simplify function calls.
        format_author = partial(Chrome(self.env).format_author, req)
        if not content:
            args = []
            compact = None
            kw = {}
            top = 5
        else:
            args, kw = parse_args(content)
            compact = 'compact' in args and True
            top = as_int(kw.get('top'), 5, min=0)

        if name == 'LastVoted':
            lst = tag.ul()
            for i in self.get_votes(req, top=top):
                resource = Resource(i[0], i[1])
                # Anotate who and when.
                voted = ('by %s at %s'
                         % (format_author(i[3]),
                            format_datetime(to_datetime(i[4]))))
                lst(tag.li(tag.a(
                    get_resource_description(env, resource, compact and
                                             'compact' or 'default'),
                    href=get_resource_url(env, resource, formatter.href),
                    title=(compact and '%+i %s' % (i[2], voted) or None)),
                    (not compact and Markup(' %s %s' % (tag.b('%+i' % i[2]),
                                                        voted)) or '')))
            return lst

        elif name == 'TopVoted':
            realm = kw.get('realm')
            lst = tag.ul()
            for i in self.get_top_voted(req, realm=realm, top=top):
                if 'up-only' in args and i[2] < 1:
                    break
                resource = Resource(i[0], i[1])
                lst(tag.li(tag.a(
                    get_resource_description(env, resource, compact and
                                             'compact' or 'default'),
                    href=get_resource_url(env, resource, formatter.href),
                    title=(compact and '%+i' % i[2] or None)),
                    (not compact and ' (%+i)' % i[2] or '')))
            return lst

        elif name == 'VoteList':
            lst = tag.ul()
            resource = resource_from_path(env, req.path_info)
            for i in self.get_votes(req, resource, top=top):
                vote = ('at %s' % format_datetime(to_datetime(i[4])))
                lst(tag.li(
                    compact and format_author(i[3]) or
                    Markup(u'%s by %s %s' % (tag.b('%+i' % i[2]),
                                             tag(format_author(i[3])), vote)),
                    title=(compact and '%+i %s' % (i[2], vote) or None)))
            return lst
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:60,代码来源:__init__.py


示例2: test_resource_repository

    def test_resource_repository(self):
        res = Resource('repository', 'testrepo')
        self.assertEqual('Repository testrepo',
                         get_resource_description(self.env, res))
        self.assertEqual('/trac.cgi/browser/testrepo',
                         get_resource_url(self.env, res, self.env.href))

        res = Resource('repository', '')  # default repository
        self.assertEqual('Default repository',
                         get_resource_description(self.env, res))
        self.assertEqual('/trac.cgi/browser',
                         get_resource_url(self.env, res, self.env.href))
开发者ID:exocad,项目名称:exotrac,代码行数:12,代码来源:api.py


示例3: test_resource_changeset

    def test_resource_changeset(self):
        res = Resource('changeset', '42')
        self.assertEqual('Changeset 42', get_resource_description(self.env, res))
        self.assertEqual('/trac.cgi/changeset/42',
                         get_resource_url(self.env, res, self.env.href))

        repo = Resource('repository', 'repo')
        res = Resource('changeset', '42', parent=repo)
        self.assertEqual('Changeset 42 in repo',
                         get_resource_description(self.env, res))
        self.assertEqual('/trac.cgi/changeset/42/repo',
                         get_resource_url(self.env, res, self.env.href))
开发者ID:exocad,项目名称:exotrac,代码行数:12,代码来源:api.py


示例4: _do_view

 def _do_view(self, env, req, form):
     data = {}
     form_id = form.resource.id
     data['page_title'] = get_resource_description(env, form.resource,
                                                   href=req.href)
     data['title'] = get_resource_shortname(env, form.resource)
     # prime list with current state
     subcontext, author, time = self.get_tracform_meta(form_id)[3:6]
     if not subcontext == '':
         data['subcontext'] = subcontext
     state = self.get_tracform_state(form_id)
     data['fields'] = self._render_fields(form_id, state)
     history = [{'author': author, 'time': time,
                 'old_state': state}]
     # add recorded old_state
     records = self.get_tracform_history(form_id)
     for author, time, old_state in records:
         history.append({'author': author, 'time': time,
                         'old_state': old_state})
     data['history'] = parse_history(history)
     # show reset button in case of existing data and proper permission
     data['allow_reset'] = req.perm(form.resource) \
                           .has_permission('FORM_RESET') and form.has_data
     add_stylesheet(req, 'tracforms/tracforms.css')
     return 'form.html', data, None
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:25,代码来源:web_ui.py


示例5: get_resource_description

 def get_resource_description(self, resource, format="default", context=None, **kwargs):
     page = WikiPage(self.env, resource.id)
     if page.exists:
         return get_resource_description(self.env, page.resource, format, **kwargs)
     rid = to_unicode(resource.id)
     if format in ("compact", "default"):
         return rid
     else:
         return u"tag:%s" % rid
开发者ID:okamototk,项目名称:kanonconductor,代码行数:9,代码来源:api.py


示例6: describe_tagged_resource

 def describe_tagged_resource(self, req, resource):
     """Returns a short description of a taggable resource."""
     provider = self._get_provider(resource.realm)
     try:
         return provider.describe_tagged_resource(req, resource)
     except (AttributeError, NotImplementedError):
         # Fallback to resource provider method.
         self.env.log.info('ITagProvider %r does not implement '
                           'describe_tagged_resource()' % provider)
         return get_resource_description(self.env, resource, 'summary')
开发者ID:kzhamaji,项目名称:TracTagsPlugin,代码行数:10,代码来源:api.py


示例7: test_global_neighborhood_report

    def test_global_neighborhood_report(self):
        target = resource.Neighborhood("global", None).child(self.resource)

        self.assertEquals("[global:] report:1", resource.get_resource_description(self.env, target))
        self.assertEquals("[global:] report:1", resource.get_resource_name(self.env, target))
        self.assertEquals("[global:] report:1", resource.get_resource_shortname(self.env, target))
        self.assertEquals("[global:] report:1 at version None", resource.get_resource_summary(self.env, target))
        self.assertEquals(
            "http://example.org/trac.cgi/report/1", resource.get_resource_url(self.env, target, self.env.href)
        )
开发者ID:rvelezc,项目名称:rafaelvelez.us-backup,代码行数:10,代码来源:resource.py


示例8: filter_stream

 def filter_stream(self, req, method, filename, stream, data):
     
     if req.path_info.startswith('/wiki/'):
         if data and data.has_key('page') and hasattr(data['page'], 'resource'):
             title = data['title']
             filter = Transformer('//div[@id="pagepath"]')
             filter = filter.empty()
             filter = filter.append( tag.a( 'wiki:', href = req.href.wiki(), class_ = 'pathentry first' ) )
            
             resource = data['page'].resource
             relation_system = ResourceRelationSystem(self.env)
             tree = relation_system.get_cached_tree(req)    
             add_stylesheet(req, 'wikimenu/css/superfish.css')
             add_script(req, 'wikimenu/js/jquery.bgiframe.min.js')
             add_script(req, 'wikimenu/js/superfish.js')
             add_script(req, 'wikimenu/js/popup.js')
             resources = []
             for res in relation_system.get_ancestors(resource, tree=tree):
                 resources.append(res)
             for res in reversed( resources ):
                 label = get_resource_description(self.env, res)
                 if res.realm=='wiki':
                     if res.id and WikiSystem(self.env).has_page(res.id):
                         
                         menu = tag.ul( )
                                                     
                         for res_child in relation_system.get_children(res):
                             child_label = get_resource_description(self.env, res_child)
                             if res_child.realm=='wiki':
                                 if res_child.id and WikiSystem(self.env).has_page(res_child.id):
                                     anc = tag.a(child_label, href = req.href.wiki(child_label))
                                     menu.append(tag.li( anc ))
                                     
                         
                         filter = filter.append( tag.ul( tag.li( 
                             tag.a(label, href=req.href.wiki(label) ),
                                 menu ), class_= 'wiki_menu' ) )
                         if title != label:
                             filter = filter.append( tag.span( ' / ', 
                                     class_ = 'pathentry sep' ) )
             remove_tran = '//a[@title="View ' + title + '"]'
             return stream | filter
     return stream
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:43,代码来源:wiki.py


示例9: test_product_neighborhood_wiki

    def test_product_neighborhood_wiki(self):
        target = resource.Neighborhood("product", u"xü").child(self.resource)

        self.assertEquals(u"TestPage", resource.get_resource_description(self.env, target))
        self.assertEquals(u"TestPage", resource.get_resource_name(self.env, target))
        self.assertEquals(u"TestPage", resource.get_resource_shortname(self.env, target))
        self.assertEquals(u"TestPage", resource.get_resource_summary(self.env, target))
        self.assertEquals(
            "http://example.org/trac.cgi/products/x%C3%BC/wiki/TestPage?version=2",
            resource.get_resource_url(self.env, target, self.env.href),
        )
开发者ID:rvelezc,项目名称:rafaelvelez.us-backup,代码行数:11,代码来源:resource.py


示例10: test_global_neighborhood_wiki

    def test_global_neighborhood_wiki(self):
        target = resource.Neighborhood("global", None).child(self.resource)

        self.assertEquals("TestPage", resource.get_resource_description(self.env, target))
        self.assertEquals("TestPage", resource.get_resource_name(self.env, target))
        self.assertEquals("TestPage", resource.get_resource_shortname(self.env, target))
        self.assertEquals("TestPage", resource.get_resource_summary(self.env, target))
        self.assertEquals(
            "http://example.org/trac.cgi/wiki/TestPage?version=2",
            resource.get_resource_url(self.env, target, self.env.href),
        )
开发者ID:rvelezc,项目名称:rafaelvelez.us-backup,代码行数:11,代码来源:resource.py


示例11: test_product_neighborhood_report

    def test_product_neighborhood_report(self):
        target = resource.Neighborhood("product", u"xü").child(self.resource)

        self.assertEquals(u"[product:xü] report:1", resource.get_resource_description(self.env, target))
        self.assertEquals(u"[product:xü] report:1", resource.get_resource_name(self.env, target))
        self.assertEquals(u"[product:xü] report:1", resource.get_resource_shortname(self.env, target))
        self.assertEquals(u"[product:xü] report:1 at version None", resource.get_resource_summary(self.env, target))
        self.assertEquals(
            "http://example.org/trac.cgi/products/x%C3%BC/report/1",
            resource.get_resource_url(self.env, target, self.env.href),
        )
开发者ID:rvelezc,项目名称:rafaelvelez.us-backup,代码行数:11,代码来源:resource.py


示例12: test_global_neighborhood_milestone

    def test_global_neighborhood_milestone(self):
        target = resource.Neighborhood("global", None).child(self.resource)

        self.assertEquals("[global:] Milestone milestone1", resource.get_resource_description(self.env, target))
        self.assertEquals("[global:] Milestone milestone1", resource.get_resource_name(self.env, target))
        self.assertEquals("milestone1", resource.get_resource_shortname(self.env, target))
        self.assertEquals("[global:] Milestone milestone1", resource.get_resource_summary(self.env, target))
        self.assertEquals(
            "http://example.org/trac.cgi/milestone/milestone1",
            resource.get_resource_url(self.env, target, self.env.href),
        )
开发者ID:rvelezc,项目名称:rafaelvelez.us-backup,代码行数:11,代码来源:resource.py


示例13: get_resource_description

 def get_resource_description(self, resource, format='default', context=None,
                              **kwargs):
     page = WikiPage(self.env, resource.id)
     if page.exists:
         return get_resource_description(self.env, page.resource, format,
                                         **kwargs)
     rid = to_unicode(resource.id)
     if format in ('compact', 'default'):
         return rid
     else:
         return u'tag:%s' % rid
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:11,代码来源:api.py


示例14: test_resource_source

    def test_resource_source(self):
        res = Resource('source', '/trunk/src')
        self.assertEqual('path /trunk/src',
                         get_resource_description(self.env, res))
        self.assertEqual('/trac.cgi/browser/trunk/src',
                         get_resource_url(self.env, res, self.env.href))

        repo = Resource('repository', 'repo')
        res = Resource('source', '/trunk/src', parent=repo)
        self.assertEqual('path /trunk/src in repo',
                         get_resource_description(self.env, res))
        self.assertEqual('/trac.cgi/browser/repo/trunk/src',
                         get_resource_url(self.env, res, self.env.href))

        repo = Resource('repository', 'repo')
        res = Resource('source', '/trunk/src', version=42, parent=repo)
        self.assertEqual('path /trunk/[email protected] in repo',
                         get_resource_description(self.env, res))
        self.assertEqual('/trac.cgi/browser/repo/trunk/src?rev=42',
                         get_resource_url(self.env, res, self.env.href))
开发者ID:exocad,项目名称:exotrac,代码行数:20,代码来源:api.py


示例15: test_global_neighborhood_ticket

    def test_global_neighborhood_ticket(self):
        nbh = resource.Neighborhood("global", None)
        data = dict(summary="Ticket summary", description="Ticket description", type="enhancement", status="new")
        target = nbh.child("ticket", self._new_ticket(self.global_env, data))

        self.assertEquals("[global:] Ticket #1", resource.get_resource_description(self.env, target))
        self.assertEquals("[global:] Ticket #1", resource.get_resource_name(self.env, target))
        self.assertEquals("[global:] #1", resource.get_resource_shortname(self.env, target))
        self.assertEquals("enhancement: Ticket summary (new)", resource.get_resource_summary(self.env, target))
        self.assertEquals(
            "http://example.org/trac.cgi/ticket/1", resource.get_resource_url(self.env, target, self.env.href)
        )
开发者ID:rvelezc,项目名称:rafaelvelez.us-backup,代码行数:12,代码来源:resource.py


示例16: test_product_neighborhood_ticket

    def test_product_neighborhood_ticket(self):
        nbh = resource.Neighborhood("product", u"xü")
        data = dict(summary="Ticket summary", description="Ticket description", type="task", status="accepted")
        target = nbh.child("ticket", self._new_ticket(self.env1, data))

        self.assertEquals(u"[product:xü] Ticket #1", resource.get_resource_description(self.env, target))
        self.assertEquals(u"[product:xü] Ticket #1", resource.get_resource_name(self.env, target))
        self.assertEquals(u"[product:xü] #1", resource.get_resource_shortname(self.env, target))
        self.assertEquals(u"task: Ticket summary (accepted)", resource.get_resource_summary(self.env, target))
        self.assertEquals(
            "http://example.org/trac.cgi/products/x%C3%BC/ticket/1",
            resource.get_resource_url(self.env, target, self.env.href),
        )
开发者ID:rvelezc,项目名称:rafaelvelez.us-backup,代码行数:13,代码来源:resource.py


示例17: render_timeline_event

 def render_timeline_event(self, context, field, event):
     # Decompose event data.
     id = event[3]
     # Return apropriate content.
     resource = Resource("downloads", id)
     if field == "url":
         if context.req.perm.has_permission("DOWNLOADS_VIEW", resource):
             return get_resource_url(self.env, resource, context.req.href)
         else:
             return "#"
     elif field == "title":
         return tag("New download ", tag.em(get_resource_name(self.env, resource)), " created")
     elif field == "description":
         return get_resource_description(self.env, resource, "summary")
开发者ID:nagyistoce,项目名称:trac-downloads,代码行数:14,代码来源:timeline.py


示例18: test_product_neighborhood_milestone

    def test_product_neighborhood_milestone(self):
        target = resource.Neighborhood('product', u'xü').child(self.resource)

        self.assertEquals(u"[product:xü] Milestone milestone1",
                          resource.get_resource_description(self.env, target))
        self.assertEquals(u"[product:xü] Milestone milestone1",
                          resource.get_resource_name(self.env, target))
        self.assertEquals(u"milestone1",
                          resource.get_resource_shortname(self.env, target))
        self.assertEquals(u"[product:xü] Milestone milestone1",
                          resource.get_resource_summary(self.env, target))
        self.assertEquals('http://example.org/trac.cgi/products/x%C3%BC/milestone/milestone1',
                          resource.get_resource_url(self.env,
                                                    target, self.env.href))
开发者ID:mohsadki,项目名称:dargest,代码行数:14,代码来源:resource.py


示例19: test_product_neighborhood_attachments

    def test_product_neighborhood_attachments(self):
        target = resource.Neighborhood('product', u'xü').child(self.resource)

        self.assertEquals(u"[product:xü] Attachment 'foo.txt' in [product:xü] Ticket #1",
                          resource.get_resource_description(self.env, target))
        self.assertEquals(u"[product:xü] Attachment 'foo.txt' in [product:xü] Ticket #1",
                          resource.get_resource_name(self.env, target))
        self.assertEquals(u"[product:xü] foo.txt ([product:xü] Ticket #1)",
                          resource.get_resource_shortname(self.env, target))
        self.assertEquals('Product Bar',
                          resource.get_resource_summary(self.env, target))
        self.assertEquals('http://example.org/trac.cgi/products/x%C3%BC/attachment/ticket/1/foo.txt',
                          resource.get_resource_url(self.env,
                                                    target, self.env.href))
开发者ID:mohsadki,项目名称:dargest,代码行数:14,代码来源:resource.py


示例20: test_global_neighborhood_attachments

    def test_global_neighborhood_attachments(self):
        target = resource.Neighborhood('global', None).child(self.resource)

        self.assertEquals("[global:] Attachment 'foo.txt' in [global:] Ticket #1",
                          resource.get_resource_description(self.env, target))
        self.assertEquals("[global:] Attachment 'foo.txt' in [global:] Ticket #1",
                          resource.get_resource_name(self.env, target))
        self.assertEquals("[global:] foo.txt ([global:] Ticket #1)",
                          resource.get_resource_shortname(self.env, target))
        self.assertEquals('Global Bar',
                          resource.get_resource_summary(self.env, target))
        self.assertEquals('http://example.org/trac.cgi/attachment/ticket/1/foo.txt',
                          resource.get_resource_url(self.env,
                                                    target, self.env.href))
开发者ID:mohsadki,项目名称:dargest,代码行数:14,代码来源:resource.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python resource.get_resource_url函数代码示例发布时间:2022-05-27
下一篇:
Python perm.PermissionSystem类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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