本文整理汇总了Python中trac.attachment.Attachment.reparent_all方法的典型用法代码示例。如果您正苦于以下问题:Python Attachment.reparent_all方法的具体用法?Python Attachment.reparent_all怎么用?Python Attachment.reparent_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.attachment.Attachment
的用法示例。
在下文中一共展示了Attachment.reparent_all方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: rename
# 需要导入模块: from trac.attachment import Attachment [as 别名]
# 或者: from trac.attachment.Attachment import reparent_all [as 别名]
def rename(self, new_name):
"""Rename wiki page in-place, keeping the history intact.
Renaming a page this way will eventually leave dangling references
to the old page - which litterally doesn't exist anymore.
"""
assert self.exists, "Cannot rename non-existent page"
if not validate_page_name(new_name):
raise TracError(_("Invalid Wiki page name '%(name)s'",
name=new_name))
old_name = self.name
with self.env.db_transaction as db:
new_page = WikiPage(self.env, new_name)
if new_page.exists:
raise TracError(_("Can't rename to existing %(name)s page.",
name=new_name))
db("UPDATE wiki SET name=%s WHERE name=%s", (new_name, old_name))
# Invalidate page name cache
del WikiSystem(self.env).pages
# Reparent attachments
from trac.attachment import Attachment
Attachment.reparent_all(self.env, 'wiki', old_name, 'wiki',
new_name)
self.name = new_name
self.env.log.info('Renamed page %s to %s', old_name, new_name)
for listener in WikiSystem(self.env).change_listeners:
if hasattr(listener, 'wiki_page_renamed'):
listener.wiki_page_renamed(self, old_name)
示例2: update
# 需要导入模块: from trac.attachment import Attachment [as 别名]
# 或者: from trac.attachment.Attachment import reparent_all [as 别名]
def update(self, author=None):
"""Update the milestone.
"""
self.name = simplify_whitespace(self.name)
if not self.name:
raise TracError(_("Invalid milestone name."))
old = self._old.copy()
with self.env.db_transaction as db:
if self.name != old['name']:
# Update milestone field in tickets
self.move_tickets(self.name, author, "Milestone renamed")
# Reparent attachments
Attachment.reparent_all(self.env, self.realm, old['name'],
self.realm, self.name)
self.env.log.info("Updating milestone '%s'", old['name'])
db("""UPDATE milestone
SET name=%s, due=%s, completed=%s, description=%s
WHERE name=%s
""", (self.name, to_utimestamp(self.due),
to_utimestamp(self.completed),
self.description, old['name']))
self.checkin()
# Fields need reset if renamed or completed/due changed
TicketSystem(self.env).reset_ticket_fields()
old_values = dict((k, v) for k, v in old.iteritems()
if getattr(self, k) != v)
for listener in TicketSystem(self.env).milestone_change_listeners:
listener.milestone_changed(self, old_values)
示例3: do_rename
# 需要导入模块: from trac.attachment import Attachment [as 别名]
# 或者: from trac.attachment.Attachment import reparent_all [as 别名]
def do_rename(db):
cursor = db.cursor()
new_page = WikiPage(self.env, new_name, db=db)
if new_page.exists:
raise TracError(_("Can't rename to existing %(name)s page.", name=new_name))
cursor.execute("UPDATE wiki SET name=%s WHERE name=%s", (new_name, old_name))
# Invalidate page name cache
del WikiSystem(self.env).pages
# Reparent attachments
from trac.attachment import Attachment
Attachment.reparent_all(self.env, "wiki", old_name, "wiki", new_name)
示例4: update
# 需要导入模块: from trac.attachment import Attachment [as 别名]
# 或者: from trac.attachment.Attachment import reparent_all [as 别名]
def update(self, db=None):
"""Update the milestone.
:since 1.0: the `db` parameter is no longer needed and will be removed
in version 1.1.1
"""
self.name = simplify_whitespace(self.name)
if not self.name:
raise TracError(_("Invalid milestone name."))
old = self._old.copy()
with self.env.db_transaction as db:
old_name = old['name']
self.env.log.info("Updating milestone '%s'", self.name)
db("""UPDATE milestone
SET name=%s, due=%s, completed=%s, description=%s
WHERE name=%s
""", (self.name, to_utimestamp(self.due),
to_utimestamp(self.completed),
self.description, old_name))
self.checkin()
if self.name != old_name:
# Update milestone field in tickets
self.env.log.info("Updating milestone field of all tickets "
"associated with milestone '%s'", self.name)
db("UPDATE ticket SET milestone=%s WHERE milestone=%s",
(self.name, old_name))
TicketSystem(self.env).reset_ticket_fields()
# Reparent attachments
Attachment.reparent_all(self.env, 'milestone', old_name,
'milestone', self.name)
old_values = dict((k, v) for k, v in old.iteritems()
if getattr(self, k) != v)
for listener in TicketSystem(self.env).milestone_change_listeners:
listener.milestone_changed(self, old_values)
ResourceSystem(self.env).resource_changed(self, old_values)
示例5: do_update
# 需要导入模块: from trac.attachment import Attachment [as 别名]
# 或者: from trac.attachment.Attachment import reparent_all [as 别名]
def do_update(db):
cursor = db.cursor()
old_name = self._old['name']
self.env.log.info('Updating milestone "%s"' % self.name)
cursor.execute("""
UPDATE milestone
SET name=%s,due=%s,completed=%s,description=%s WHERE name=%s
""", (self.name, to_utimestamp(self.due),
to_utimestamp(self.completed),
self.description, old_name))
if self.name != old_name:
# Update milestone field in tickets
self.env.log.info('Updating milestone field of all tickets '
'associated with milestone "%s"' % self.name)
cursor.execute("""
UPDATE ticket SET milestone=%s WHERE milestone=%s
""", (self.name, old_name))
TicketSystem(self.env).reset_ticket_fields()
# Reparent attachments
Attachment.reparent_all(self.env, 'milestone', old_name,
'milestone', self.name)