本文整理汇总了Python中trac.attachment.Attachment.delete_all方法的典型用法代码示例。如果您正苦于以下问题:Python Attachment.delete_all方法的具体用法?Python Attachment.delete_all怎么用?Python Attachment.delete_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.attachment.Attachment
的用法示例。
在下文中一共展示了Attachment.delete_all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete
# 需要导入模块: from trac.attachment import Attachment [as 别名]
# 或者: from trac.attachment.Attachment import delete_all [as 别名]
def delete(self, db=None):
"""Remove a build configuration and all dependent objects from the
database."""
assert self.exists, "Cannot delete non-existing configuration"
if not db:
db = self.env.get_db_cnx()
handle_ta = True
else:
handle_ta = False
for platform in list(TargetPlatform.select(self.env, self.name, db=db)):
platform.delete(db=db)
for build in list(Build.select(self.env, config=self.name, db=db)):
build.delete(db=db)
# Delete attachments
Attachment.delete_all(self.env, "build", self.resource.id, db)
cursor = db.cursor()
cursor.execute("DELETE FROM bitten_config WHERE name=%s", (self.name,))
if handle_ta:
db.commit()
self._old_name = None
示例2: delete
# 需要导入模块: from trac.attachment import Attachment [as 别名]
# 或者: from trac.attachment.Attachment import delete_all [as 别名]
def delete(self, version=0):
""" Deletes a specific version, or if none is provided
then all versions will be deleted. If all (or just one version exists) it
will also delete all comments and any attachments attached to the post. """
if version:
sql = "DELETE FROM fullblog_posts WHERE name=%s AND version=%s"
args = (self.name, version)
else:
sql = "DELETE FROM fullblog_posts WHERE name=%s"
args = (self.name,)
if hasattr(self.env, 'db_transaction'):
self.env.db_transaction(sql, args)
db = None
else:
db = self.env.get_db_cnx()
cursor = db.cursor()
cursor.execute(sql, args)
db.commit()
if not len(self.get_versions()):
# Delete comments
for comment in self.get_comments():
comment.delete()
# Delete attachments
if db is not None:
Attachment.delete_all(self.env, 'blog', self.name, db)
else:
Attachment.delete_all(self.env, 'blog', self.name)
return True
示例3: test_rename_page
# 需要导入模块: from trac.attachment import Attachment [as 别名]
# 或者: from trac.attachment.Attachment import delete_all [as 别名]
def test_rename_page(self):
data = (1, 42, 'joe', '::1', 'Bla bla', 'Testing', 0)
self.env.db_transaction(
"INSERT INTO wiki VALUES(%s,%s,%s,%s,%s,%s,%s,%s)",
('TestPage',) + data)
attachment = Attachment(self.env, 'wiki', 'TestPage')
attachment.insert('foo.txt', StringIO(), 0, 1)
page = WikiPage(self.env, 'TestPage')
page.rename('PageRenamed')
self.assertEqual('PageRenamed', page.name)
self.assertEqual('PageRenamed', page.resource.id)
self.assertEqual([data], self.env.db_query("""
SELECT version, time, author, ipnr, text, comment, readonly
FROM wiki WHERE name=%s
""", ('PageRenamed',)))
attachments = Attachment.select(self.env, 'wiki', 'PageRenamed')
self.assertEqual('foo.txt', attachments.next().filename)
self.assertRaises(StopIteration, attachments.next)
Attachment.delete_all(self.env, 'wiki', 'PageRenamed')
old_page = WikiPage(self.env, 'TestPage')
self.assertFalse(old_page.exists)
self.assertEqual([], self.env.db_query("""
SELECT version, time, author, ipnr, text, comment, readonly
FROM wiki WHERE name=%s
""", ('TestPage',)))
listener = TestWikiChangeListener(self.env)
self.assertEqual((page, 'TestPage'), listener.renamed[0])
示例4: do_delete
# 需要导入模块: from trac.attachment import Attachment [as 别名]
# 或者: from trac.attachment.Attachment import delete_all [as 别名]
def do_delete(db):
cursor = db.cursor()
Attachment.delete_all(self.env, self.resource.realm, self.resource.id, db)
cursor.execute("""
DELETE FROM mailinglistraw WHERE id IN
(SELECT raw FROM mailinglistmessages WHERE id = %s)""", (self.id,))
cursor.execute('DELETE FROM mailinglistmessages WHERE id = %s', (self.id,))
示例5: test_rename_page
# 需要导入模块: from trac.attachment import Attachment [as 别名]
# 或者: from trac.attachment.Attachment import delete_all [as 别名]
def test_rename_page(self):
cursor = self.db.cursor()
data = (1, 42, 'joe', '::1', 'Bla bla', 'Testing', 0)
cursor.execute("INSERT INTO wiki VALUES(%s,%s,%s,%s,%s,%s,%s,%s)",
('TestPage',) + data)
attachment = Attachment(self.env, 'wiki', 'TestPage')
attachment.insert('foo.txt', StringIO(), 0, 1)
page = WikiPage(self.env, 'TestPage')
page.rename('PageRenamed')
self.assertEqual('PageRenamed', page.name)
cursor.execute("SELECT version,time,author,ipnr,text,comment,"
"readonly FROM wiki WHERE name=%s", ('PageRenamed',))
self.assertEqual(data, cursor.fetchone())
self.assertEqual(None, cursor.fetchone())
attachments = Attachment.select(self.env, 'wiki', 'PageRenamed')
self.assertEqual('foo.txt', attachments.next().filename)
self.assertRaises(StopIteration, attachments.next)
Attachment.delete_all(self.env, 'wiki', 'PageRenamed', self.db)
old_page = WikiPage(self.env, 'TestPage')
self.assertEqual(False, old_page.exists)
cursor.execute("SELECT version,time,author,ipnr,text,comment,"
"readonly FROM wiki WHERE name=%s", ('TestPage',))
self.assertEqual(None, cursor.fetchone())
listener = TestWikiChangeListener(self.env)
self.assertEqual((page, 'TestPage'), listener.renamed[0])
示例6: do_delete
# 需要导入模块: from trac.attachment import Attachment [as 别名]
# 或者: from trac.attachment.Attachment import delete_all [as 别名]
def do_delete(db):
Attachment.delete_all(self.env, 'ticket', self.id, db)
cursor = db.cursor()
cursor.execute("DELETE FROM ticket WHERE id=%s", (self.id,))
cursor.execute("DELETE FROM ticket_change WHERE ticket=%s",
(self.id,))
cursor.execute("DELETE FROM ticket_custom WHERE ticket=%s",
(self.id,))
示例7: delete
# 需要导入模块: from trac.attachment import Attachment [as 别名]
# 或者: from trac.attachment.Attachment import delete_all [as 别名]
def delete(self):
"""Delete the ticket.
"""
with self.env.db_transaction as db:
Attachment.delete_all(self.env, self.realm, self.id)
db("DELETE FROM ticket WHERE id=%s", (self.id,))
db("DELETE FROM ticket_change WHERE ticket=%s", (self.id,))
db("DELETE FROM ticket_custom WHERE ticket=%s", (self.id,))
for listener in TicketSystem(self.env).change_listeners:
listener.ticket_deleted(self)
示例8: delete
# 需要导入模块: from trac.attachment import Attachment [as 别名]
# 或者: from trac.attachment.Attachment import delete_all [as 别名]
def delete(self, db=None):
db, handle_ta = self._get_db_for_write(db)
Attachment.delete_all(self.env, 'ticket', self.id, db)
cursor = db.cursor()
cursor.execute("DELETE FROM ticket WHERE id=%s", (self.id,))
cursor.execute("DELETE FROM ticket_change WHERE ticket=%s", (self.id,))
cursor.execute("DELETE FROM ticket_custom WHERE ticket=%s", (self.id,))
if handle_ta:
db.commit()
for listener in TicketSystem(self.env).change_listeners:
listener.ticket_deleted(self)
示例9: delete
# 需要导入模块: from trac.attachment import Attachment [as 别名]
# 或者: from trac.attachment.Attachment import delete_all [as 别名]
def delete(self, db=None):
"""Delete the ticket.
:since 1.0: the `db` parameter is no longer needed and will be removed
in version 1.1.1
"""
with self.env.db_transaction as db:
Attachment.delete_all(self.env, 'ticket', self.id, db)
db("DELETE FROM ticket WHERE id=%s", (self.id,))
db("DELETE FROM ticket_change WHERE ticket=%s", (self.id,))
db("DELETE FROM ticket_custom WHERE ticket=%s", (self.id,))
for listener in TicketSystem(self.env).change_listeners:
listener.ticket_deleted(self)
示例10: remove
# 需要导入模块: from trac.attachment import Attachment [as 别名]
# 或者: from trac.attachment.Attachment import delete_all [as 别名]
def remove(self, build):
"""Delete what is linked to the build."""
print "Deleting items for build %r" % (build,)
db = self.env.get_db_cnx()
cursor = db.cursor()
print "Determining associated config."
cursor.execute("SELECT config FROM bitten_build WHERE id=%s", (build,))
config = cursor.fetchone()[0]
print "Collecting log files."
filenames = self._log_files(cursor, build)
try:
print "Deleting bitten_log entries."
cursor.execute("DELETE FROM bitten_log WHERE build=%s", (build,))
print "Deleting bitten_report_item_entries."
cursor.execute("DELETE FROM bitten_report_item WHERE report IN ("
"SELECT bitten_report.id FROM bitten_report "
"WHERE bitten_report.build=%s"
")", (build,))
print "Deleting bitten_report entires."
cursor.execute("DELETE FROM bitten_report WHERE build=%s",
(build,))
print "Deleting bitten_step entries."
cursor.execute("DELETE FROM bitten_step WHERE build=%s", (build,))
print "Delete bitten_build entry."
cursor.execute("DELETE FROM bitten_build WHERE id=%s", (build,))
except:
db.rollback()
print "Build deletion failed. Database rolled back."
raise
print "Bitten database changes committed."
db.commit()
print "Removing log files."
for filename in filenames:
os.remove(filename)
print "Removing attachments."
resource = Resource('build', '%s/%s' % (config, build))
Attachment.delete_all(self.env, 'build', resource.id, db)
示例11: _do_invalidate
# 需要导入模块: from trac.attachment import Attachment [as 别名]
# 或者: from trac.attachment.Attachment import delete_all [as 别名]
def _do_invalidate(self, req, build, db):
self.log.info('Invalidating build %d', build.id)
for step in BuildStep.select(self.env, build=build.id, db=db):
step.delete(db=db)
build.slave = None
build.started = 0
build.stopped = 0
build.last_activity = 0
build.status = Build.PENDING
build.slave_info = {}
build.update()
Attachment.delete_all(self.env, 'build', build.resource.id, db)
db.commit()
req.redirect(req.href.build(build.config))
示例12: _process_build_cancellation
# 需要导入模块: from trac.attachment import Attachment [as 别名]
# 或者: from trac.attachment.Attachment import delete_all [as 别名]
def _process_build_cancellation(self, req, config, build):
self.log.info('Build slave %r cancelled build %d', build.slave,
build.id)
build.status = Build.PENDING
build.slave = None
build.slave_info = {}
build.started = 0
db = self.env.get_db_cnx()
for step in list(BuildStep.select(self.env, build=build.id, db=db)):
step.delete(db=db)
build.update(db=db)
Attachment.delete_all(self.env, 'build', build.resource.id, db)
db.commit()
for listener in BuildSystem(self.env).listeners:
listener.build_aborted(build)
self._send_response(req, 204, '', {})
示例13: do_delete
# 需要导入模块: from trac.attachment import Attachment [as 别名]
# 或者: from trac.attachment.Attachment import delete_all [as 别名]
def do_delete(db):
cursor = db.cursor()
if version is None:
# Delete a wiki page completely
cursor.execute("DELETE FROM wiki WHERE name=%s", (self.name,))
self.env.log.info("Deleted page %s" % self.name)
else:
# Delete only a specific page version
cursor.execute("DELETE FROM wiki WHERE name=%s and version=%s", (self.name, version))
self.env.log.info("Deleted version %d of page %s" % (version, self.name))
if version is None or version == self.version:
self._fetch(self.name, None, db)
if not self.exists:
# Invalidate page name cache
del WikiSystem(self.env).pages
# Delete orphaned attachments
from trac.attachment import Attachment
Attachment.delete_all(self.env, "wiki", self.name, db)
示例14: delete
# 需要导入模块: from trac.attachment import Attachment [as 别名]
# 或者: from trac.attachment.Attachment import delete_all [as 别名]
def delete(self, version=None, db=None):
"""Delete one or all versions of a page.
:since 1.0: the `db` parameter is no longer needed and will be removed
in version 1.1.1
"""
assert self.exists, "Cannot delete non-existent page"
with self.env.db_transaction as db:
if version is None:
# Delete a wiki page completely
db("DELETE FROM wiki WHERE name=%s", (self.name,))
self.env.log.info("Deleted page %s", self.name)
else:
# Delete only a specific page version
db("DELETE FROM wiki WHERE name=%s and version=%s",
(self.name, version))
self.env.log.info("Deleted version %d of page %s", version,
self.name)
if version is None or version == self.version:
self._fetch(self.name, None)
if not self.exists:
# Invalidate page name cache
del WikiSystem(self.env).pages
# Delete orphaned attachments
from trac.attachment import Attachment
Attachment.delete_all(self.env, 'wiki', self.name)
# Let change listeners know about the deletion
if not self.exists:
for listener in WikiSystem(self.env).change_listeners:
listener.wiki_page_deleted(self)
ResourceSystem(self.env).resource_deleted(self)
else:
for listener in WikiSystem(self.env).change_listeners:
if hasattr(listener, 'wiki_page_version_deleted'):
listener.wiki_page_version_deleted(self)
ResourceSystem(self.env).resource_version_deleted(self)
示例15: delete
# 需要导入模块: from trac.attachment import Attachment [as 别名]
# 或者: from trac.attachment.Attachment import delete_all [as 别名]
def delete(self, version=0):
""" Deletes a specific version, or if none is provided
then all versions will be deleted. If all (or just one version exists) it
will also delete all comments and any attachments attached to the post. """
cnx = self.env.get_db_cnx()
cursor = cnx.cursor()
if version:
cursor.execute("DELETE FROM fullblog_posts "
"WHERE name=%s AND version=%s",
(self.name, version))
else:
cursor.execute("DELETE FROM fullblog_posts "
"WHERE name=%s", (self.name,))
cnx.commit()
if not len(self.get_versions()):
# Delete comments
for comment in self.get_comments():
comment.delete()
# Delete attachments
Attachment.delete_all(self.env, 'blog', self.name, cnx)
cnx.commit()
return True