本文整理汇总了Python中trac.ticket.model.Ticket._fetch_ticket方法的典型用法代码示例。如果您正苦于以下问题:Python Ticket._fetch_ticket方法的具体用法?Python Ticket._fetch_ticket怎么用?Python Ticket._fetch_ticket使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.ticket.model.Ticket
的用法示例。
在下文中一共展示了Ticket._fetch_ticket方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: StructuredMilestone
# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import _fetch_ticket [as 别名]
class StructuredMilestone(object):
"""The model for structured milestone."""
__proxy_attrs__ = ['name', 'due', 'completed', 'description', 'resource', 'exists', 'is_completed', 'is_late']
_kids = None
_level = None
def __init__(self, env, milestone=None, db=None):
self.env = env
if not isinstance(milestone, Milestone):
milestone = Milestone(env, milestone)
self.milestone = milestone
self.ticket = Ticket(self.env)
self.ticket.fields = MilestoneSystem(self.env).get_milestone_fields()
self.ticket.values = {}
self.ticket['summary'] = milestone.name
self.ticket['type'] = milestone_ticket_type
self.ticket._old={}
if self.exists:
self._fetch(milestone.name, db)
def __getattribute__(self, name):
if name in object.__getattribute__(self, "__proxy_attrs__"):
return getattr(object.__getattribute__(self, "milestone"), name)
return object.__getattribute__(self, name)
def __setattr__(self, name, value):
if name in object.__getattribute__(self, "__proxy_attrs__"):
setattr(object.__getattribute__(self, "milestone"), name, value)
else:
self.__dict__[name]=value
parent = property(fget= lambda self: self.ticket.values.get('milestone'))
is_started = property(fget=lambda self: self.ticket.values.get('started') is not None)
level = property(fget = lambda self: self._get_level(), fset = lambda self, val: self._set_level(val))
can_be_closed = property(lambda self: self._can_be_closed())
kids = property (lambda self: self._get_kids())
def _fetch(self, name, db=None):
if not db:
db = self.env.get_db_cnx()
cursor = db.cursor()
cursor.execute("SELECT id"
" FROM ticket"
" WHERE summary=%s"
" AND type=%s", (name, milestone_ticket_type))
row = cursor.fetchone()
if not row:
raise ResourceNotFound('Associated Ticket %s does not exist.' % name,
'Invalid Milestone State')
self.ticket._fetch_ticket(row[0], db)
def _get_kids(self):
if self._kids is None:
db = self.env.get_db_cnx()
cursor = db.cursor()
cursor.execute("SELECT m.name "
" FROM milestone m,"
" ticket t"
" WHERE m.name=t.summary"
" AND t.milestone=%s"
" AND t.type=%s", (self.name, milestone_ticket_type))
self._kids = [StructuredMilestone(self.env, name) for name, in cursor]
return self._kids
def _can_be_closed(self):
kids = self.kids
if kids:
for kid in kids:
if not kid.is_completed:
return False
return True
def _get_level(self):
if self._level:
return self._level
lev = 0
if self.parent:
parent_milestone = StructuredMilestone(self.env, self.parent)
if parent_milestone.exists:
lev = parent_milestone.level['index'] +1
self._level = {'index':lev, 'label': self._get_level_label(lev)}
return self._level
def _set_level(self, lev):
int_lev = int(lev)
self._level = {'index':int_lev, 'label': self._get_level_label(int_lev)}
def _get_level_label(self, idx):
label = 'undefined'
levels = IttecoEvnSetup(self.env).milestone_levels
if levels and idx < len(levels):
label = levels[idx]
return label
def delete(self, retarget_to=None, author=None, db=None):
handle_commit = False
if not db:
#.........这里部分代码省略.........