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


Python Ticket.id_is_valid方法代码示例

本文整理汇总了Python中trac.ticket.model.Ticket.id_is_valid方法的典型用法代码示例。如果您正苦于以下问题:Python Ticket.id_is_valid方法的具体用法?Python Ticket.id_is_valid怎么用?Python Ticket.id_is_valid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在trac.ticket.model.Ticket的用法示例。


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

示例1: _format_link

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import id_is_valid [as 别名]
 def _format_link(self, formatter, ns, target, label, fullmatch=None):
     intertrac = formatter.shorthand_intertrac_helper(ns, target, label,
                                                      fullmatch)
     if intertrac:
         return intertrac
     try:
         link, params, fragment = formatter.split_link(target)
         r = Ranges(link)
         if len(r) == 1:
             num = r.a
             ticket = formatter.resource('ticket', num)
             from trac.ticket.model import Ticket
             if Ticket.id_is_valid(num) and \
                     'TICKET_VIEW' in formatter.perm(ticket):
                 # TODO: watch #6436 and when done, attempt to retrieve 
                 #       ticket directly (try: Ticket(self.env, num) ...)
                 cursor = formatter.db.cursor() 
                 cursor.execute("SELECT type,summary,status,resolution "
                                "FROM ticket WHERE id=%s", (str(num),)) 
                 for type, summary, status, resolution in cursor:
                     title = self.format_summary(summary, status,
                                                 resolution, type)
                     href = formatter.href.ticket(num) + params + fragment
                     return tag.a(label, class_='%s ticket' % status, 
                                  title=title, href=href)
         else:
             ranges = str(r)
             if params:
                 params = '&' + params[1:]
             return tag.a(label, title='Tickets '+ranges,
                          href=formatter.href.query(id=ranges) + params)
     except ValueError:
         pass
     return tag.a(label, class_='missing ticket')
开发者ID:twisted-infra,项目名称:twisted-trac-source,代码行数:36,代码来源:api.py

示例2: test_invalid_ticket_id

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import id_is_valid [as 别名]
 def test_invalid_ticket_id(self):
     self.assertEqual(Ticket.id_is_valid(-1), False)
     self.assertEqual(Ticket.id_is_valid(0), False)
     self.assertEqual(Ticket.id_is_valid(1), True)
     self.assertEqual(Ticket.id_is_valid(1L << 31), True)
     self.assertEqual(Ticket.id_is_valid(1L << 32), False)
     self.assertRaises(ResourceNotFound, Ticket, self.env, -1)
     self.assertRaises(ResourceNotFound, Ticket, self.env, 1L << 32)
开发者ID:zjj,项目名称:trac_hack,代码行数:10,代码来源:model.py

示例3: get_deco

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import id_is_valid [as 别名]
 def get_deco(self, formatter, ns, target, label, fullmatch=None):
     link, params, fragment = formatter.split_link(target)  # @UnusedVariable
     r = Ranges(link)
     if len(r) == 1:
         num = r.a
         ticket = formatter.resource('ticket', num)
         from trac.ticket.model import Ticket
         if Ticket.id_is_valid(num) and \
                 'TICKET_VIEW' in formatter.perm(ticket):
             ticket = Ticket(self.env, num)
             fields = self.config.getlist('ticket', 'decorate_fields')
             return ['%s_is_%s' % (field, ticket.values[field]) for field in fields if field in ticket.values]
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:14,代码来源:linkdeco.py

示例4: get_tag

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import id_is_valid [as 别名]
                def get_tag(ticketId, commentId):
                    from trac.ticket.model import Ticket

                    if Ticket.id_is_valid(ticketId) and Ticket.commentid_is_valid(commentId):
                        href = "%s#comment:%s" % (formatter.href.ticket(ticketId), commentId)
                        title = _("Comment %(cnum)s for Ticket #%(id)s", cnum=commentId, id=ticketId)
                        ticket = formatter.resource("ticket", ticketId)
                        if "TICKET_VIEW" in formatter.perm(ticket):
                            for (status,) in self.env.db_query("SELECT status FROM ticket WHERE id=%s", (ticketId,)):
                                return tag.a(label, href=href, title=title, class_=status)
                        return tag.a(label, href=href, title=title)
                    return tag.a(label, class_="missing ticket")
开发者ID:exocad,项目名称:exotrac,代码行数:14,代码来源:api.py

示例5: post_process_request

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import id_is_valid [as 别名]
    def post_process_request(self, req, template, data, content_type):
        """ overridden from IRequestFilter"""
        if req.path_info.startswith('/newticket') or \
            req.path_info.startswith('/ticket'):
            add_script(req, 'hw/js/budgeting.js')
            if not data:
                return template, data, content_type
            tkt = data['ticket']

            if tkt and tkt.id and Ticket.id_is_valid(tkt.id):  # ticket is ready for saving
                if self._changed_by_author:
                    self._save_budget(tkt)
                self._budgets = None
        return template, data, content_type
开发者ID:lkraav,项目名称:trachacks,代码行数:16,代码来源:ticketbudgeting.py

示例6: _format_link

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import id_is_valid [as 别名]
 def _format_link(self, formatter, ns, target, label, fullmatch=None):
     intertrac = formatter.shorthand_intertrac_helper(ns, target, label,
                                                      fullmatch)
     if intertrac:
         return intertrac
     try:
         link, params, fragment = formatter.split_link(target)
         r = Ranges(link)
         if len(r) == 1:
             num = r.a
             ticket = formatter.resource('ticket', num)
             from trac.ticket.model import Ticket
             if Ticket.id_is_valid(num) and \
                     'TICKET_VIEW' in formatter.perm(ticket):
                 # TODO: attempt to retrieve ticket view directly,
                 #       something like: t = Ticket.view(num)
                 for type, summary, status, resolution in \
                         self.env.db_query("""
                         SELECT type, summary, status, resolution
                         FROM ticket WHERE id=%s
                         """, (str(num),)):
                     title = self.format_summary(summary, status,
                                                 resolution, type)
                     href = formatter.href.ticket(num) + params + fragment
                     return tag.a(label, title=title, href=href,
                                  class_='%s ticket' % status)
         else:
             ranges = str(r)
             if params:
                 params = '&' + params[1:]
             if isinstance(label, Markup):
                 _label = unescape(label)
             else:
                 _label = label
             label_wrap = _label.replace(',', u',\u200b')
             ranges_wrap = ranges.replace(',', u', ')
             return tag.a(label_wrap,
                          title=_("Tickets %(ranges)s", ranges=ranges_wrap),
                          href=formatter.href.query(id=ranges) + params)
     except ValueError:
         pass
     return tag.a(label, class_='missing ticket')
开发者ID:thimalk,项目名称:bloodhound-789,代码行数:44,代码来源:api.py

示例7: resource_exists

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import id_is_valid [as 别名]
    def resource_exists(self, resource):
        """
        >>> from trac.test import EnvironmentStub
        >>> from trac.resource import Resource, resource_exists
        >>> env = EnvironmentStub()

        >>> resource_exists(env, Resource('ticket', 123456))
        False

        >>> from trac.ticket.model import Ticket
        >>> t = Ticket(env)
        >>> int(t.insert())
        1
        >>> resource_exists(env, t.resource)
        True
        """
        try:
            id_ = int(resource.id)
        except (TypeError, ValueError):
            return False
        from trac.ticket.model import Ticket

        if not Ticket.id_is_valid(id_):
            return False
        if self.env.db_query("SELECT id FROM ticket WHERE id=%s", (id_,)):
            if resource.version is None:
                return True
            revcount = self.env.db_query(
                """
                SELECT count(DISTINCT time) FROM ticket_change WHERE ticket=%s
                """,
                (id_,),
            )
            return revcount[0][0] >= resource.version
        else:
            return False
开发者ID:exocad,项目名称:exotrac,代码行数:38,代码来源:api.py

示例8: system_message

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import id_is_valid [as 别名]
         return ""
     if not page.exists:
         if page_version:
             return system_message('No version "%s" for wiki page "%s"' % (page_version, page_name))
         else:
             return system_message('Wiki page "%s" does not exist' % page_name)
     out = page.text
     ctxt = Context.from_request(formatter.req, "wiki", source_obj)
 elif source_format == "source":
     if not formatter.perm.has_permission("FILE_VIEW"):
         return ""
     out, ctxt, dest_format = self._get_source(formatter, source_obj, dest_format)
 elif source_format == "ticket":
     if ":" in source_obj:
         ticket_num, source_obj = source_obj.split(":", 1)
         if not Ticket.id_is_valid(ticket_num):
             return system_message("%s is not a valid ticket id" % ticket_num)
         try:
             ticket = Ticket(self.env, ticket_num)
             if not "TICKET_VIEW" in formatter.perm(ticket.resource):
                 return ""
         except ResourceNotFound, e:
             return system_message("Ticket %s does not exist" % ticket_num)
         if ":" in source_obj:
             source_format, comment_num = source_obj.split(":", 1)
             if source_format == "comment":
                 changelog = ticket.get_changelog()
                 out = []
                 if changelog:
                     for (ts, author, field, oldval, newval, permanent) in changelog:
                         if field == "comment" and oldval == comment_num:
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:33,代码来源:macros.py

示例9: _format_link

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import id_is_valid [as 别名]
    def _format_link(self, formatter, ns, target, label, fullmatch=None):
        intertrac = formatter.shorthand_intertrac_helper(ns, target, label, fullmatch)
        if intertrac:
            return intertrac
        try:
            link, params, fragment = formatter.split_link(target)
            # NEW vvvvv
            # Short "#<ticketId>:<commentId>"
            # or    "#<ticketId>#comment:<commentId>" (last part of trac url)
            if ":" in link:

                def get_tag(ticketId, commentId):
                    from trac.ticket.model import Ticket

                    if Ticket.id_is_valid(ticketId) and Ticket.commentid_is_valid(commentId):
                        href = "%s#comment:%s" % (formatter.href.ticket(ticketId), commentId)
                        title = _("Comment %(cnum)s for Ticket #%(id)s", cnum=commentId, id=ticketId)
                        ticket = formatter.resource("ticket", ticketId)
                        if "TICKET_VIEW" in formatter.perm(ticket):
                            for (status,) in self.env.db_query("SELECT status FROM ticket WHERE id=%s", (ticketId,)):
                                return tag.a(label, href=href, title=title, class_=status)
                        return tag.a(label, href=href, title=title)
                    return tag.a(label, class_="missing ticket")

                if "#" in link:
                    arr = link.split("#")
                    if len(arr) == 2:
                        tnum, cnum = arr
                        if cnum.startswith("comment:"):
                            return get_tag(tnum, cnum[8:])
                arr = link.split(":")
                if len(arr) == 2:
                    tnum, cnum = arr
                    return get_tag(tnum, cnum)
            # NEW ^^^^^
            r = Ranges(link)
            if len(r) == 1:
                num = r.a
                ticket = formatter.resource("ticket", num)
                from trac.ticket.model import Ticket

                if Ticket.id_is_valid(num) and "TICKET_VIEW" in formatter.perm(ticket):
                    # TODO: attempt to retrieve ticket view directly,
                    #       something like: t = Ticket.view(num)
                    for type, summary, status, resolution in self.env.db_query(
                        """
                            SELECT type, summary, status, resolution
                            FROM ticket WHERE id=%s
                            """,
                        (str(num),),
                    ):
                        title = self.format_summary(summary, status, resolution, type)
                        href = formatter.href.ticket(num) + params + fragment
                        return tag.a(label, title=title, href=href, class_="%s ticket" % status)
            else:
                ranges = str(r)
                if params:
                    params = "&" + params[1:]
                label_wrap = label.replace(",", u",\u200b")
                ranges_wrap = ranges.replace(",", u", ")
                return tag.a(
                    label_wrap,
                    title=_("Tickets %(ranges)s", ranges=ranges_wrap),
                    href=formatter.href.query(id=ranges) + params,
                )
        except ValueError:
            pass
        return tag.a(label, class_="missing ticket")
开发者ID:exocad,项目名称:exotrac,代码行数:70,代码来源:api.py


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