本文整理匯總了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()