本文整理汇总了Python中trac.ticket.model.Component.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Component.delete方法的具体用法?Python Component.delete怎么用?Python Component.delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.ticket.model.Component
的用法示例。
在下文中一共展示了Component.delete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: copy_component
# 需要导入模块: from trac.ticket.model import Component [as 别名]
# 或者: from trac.ticket.model.Component import delete [as 别名]
def copy_component(source_env, dest_env, name, dest_db=None):
# In case a string gets passed in
if not isinstance(source_env, Environment):
source_env = _open_environment(source_env)
if not isinstance(dest_env, Environment):
dest_env = _open_environment(dest_env)
# Log message
source_env.log.info('DatamoverPlugin: Moving component %s to the environment at %s', name, dest_env.path)
dest_env.log.info('DatamoverPlugin: Moving component %s from the environment at %s', name, source_env.path)
# Open databases
source_db = source_env.get_db_cnx()
source_cursor = source_db.cursor()
handle_commit = True
if not dest_db:
dest_db, handle_commit = dest_env.get_db_cnx(), False
dest_cursor = dest_db.cursor()
# Remove the component from the destination
try:
dest_comp = TicketComponent(dest_env, name, db=dest_db)
dest_comp.delete(db=dest_db)
except TracError:
pass
# Copy each entry in the component table
source_cursor.execute('SELECT * FROM component WHERE name=%s',(name,))
for row in source_cursor:
comp_data = dict(zip([d[0] for d in source_cursor.description], row))
q = make_query(comp_data, 'component')
dest_cursor.execute(*q)
if handle_commit:
dest_db.commit()