本文整理汇总了Python中trac.env.Environment.with_transaction方法的典型用法代码示例。如果您正苦于以下问题:Python Environment.with_transaction方法的具体用法?Python Environment.with_transaction怎么用?Python Environment.with_transaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.env.Environment
的用法示例。
在下文中一共展示了Environment.with_transaction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Script
# 需要导入模块: from trac.env import Environment [as 别名]
# 或者: from trac.env.Environment import with_transaction [as 别名]
class Script ( object ):
def __init__(self):
while self.find_and_remove_installs():pass
(options,args) = parser.parse_args()
if(len(args) == 0) :
self.trac= p('Please type your trac path (or run this script passing it the path):')
else:
self.trac = args[0]
print "Opening trac environment"
self.env = Environment(self.trac)
self.env.with_transaction()
print "Removing T&E from trac env"
self.find_and_remove_custom_vars()
self.find_and_remove_ticket_change()
self.find_and_remove_reports()
self.remove_configuration()
self.remove_system_keys()
print "Done uninstalling"
def execute_in_trans(self, *args):
result = True
c_sql =[None]
c_params = [None]
@self.env.with_transaction()
def fn(db):
try:
cur = db.cursor()
for sql, params in args:
c_sql[0] = sql
c_params[0] = params
cur.execute(sql, params)
except Exception, e :
print 'There was a problem executing sql:%s \n \
with parameters:%s\nException:%s'%(c_sql[0], c_params[0], e);
raise e
return result