本文整理汇总了Python中transaction.Transaction.commit方法的典型用法代码示例。如果您正苦于以下问题:Python Transaction.commit方法的具体用法?Python Transaction.commit怎么用?Python Transaction.commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类transaction.Transaction
的用法示例。
在下文中一共展示了Transaction.commit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: all_unknown
# 需要导入模块: from transaction import Transaction [as 别名]
# 或者: from transaction.Transaction import commit [as 别名]
def all_unknown(self, message, *args, **kwargs):
__callstack_var_tx__ = Transaction(name=self._transactionName)
yield self.once.begin(self._transactionName)
try:
yield self.all.unknown(message, *args, **kwargs)
yield __callstack_var_tx__.commit()
except TransactionException:
yield __callstack_var_tx__.rollback()
示例2: any_unknown
# 需要导入模块: from transaction import Transaction [as 别名]
# 或者: from transaction.Transaction import commit [as 别名]
def any_unknown(self, message, *args, **kwargs):
__callstack_var_tx__ = Transaction(name=self._transactionName)
yield self.once.begin(name=self._transactionName)
try:
try:
response = yield self.any.unknown(message, *args, **kwargs)
except NoneOfTheObserversRespond:
raise DeclineMessage
yield __callstack_var_tx__.commit()
raise StopIteration(response)
except TransactionException:
yield __callstack_var_tx__.rollback()
示例3: map
# 需要导入模块: from transaction import Transaction [as 别名]
# 或者: from transaction.Transaction import commit [as 别名]
return parent.find_element_by_css_selector(selector).text
except NoSuchElementException:
return None
for hotelurl in session.query(HotelUrl).filter(HotelUrl.crawled==None):
driver.get(hotelurl.hotel_url)
description = driver.find_element_by_css_selector("#summary").text
address = driver.find_element_by_css_selector("#hp_address_subtitle")
features = driver.find_elements_by_css_selector("div.facilitiesChecklistSection")
hotel_features = {}
for category in features:
cat = category.find_element_by_css_selector("h5").text
fs = map(lambda x: x.text, category.find_elements_by_css_selector("li"))
hotel_features[cat]=fs
address = extract_address(address.text)
opinions,hotel_grade = getOpinionsAndHotelGrade(driver,hotelurl.hotel_opinion_url)
#session, hotel_url, address, hotel_grade, description, opinions, features
# print description,address,hotel_features,opinions,hotel_grade
transaction = Transaction(session,hotelurl,address,hotel_grade,description,opinions,hotel_features)
transaction.commit()
示例4: str
# 需要导入模块: from transaction import Transaction [as 别名]
# 或者: from transaction.Transaction import commit [as 别名]
key = args[1]
value = args[2]
transaction.set(key, value)
elif args[0] == "GET":
key = args[1]
value = transaction.get(key)
print value if value != None else "NULL"
elif args[0] == "UNSET":
key = args[1]
transaction.unset(key)
elif args[0] == "NUMEQUALTO":
value = args[1]
print str(transaction.numEqualTo(value))
elif args[0] == "BEGIN":
transaction = transaction.createChild()
elif args[0] == "COMMIT":
transaction = transaction.commit({})
elif args[0] == "ROLLBACK":
if transaction.parent != None:
transaction = transaction.parent
else:
print "NO TRANSACTION"
else:
raise Exception("Bad argument passed")
except:
print "Command not recognized or malformed"
print "Commands: SET, GET, UNSET, NUMEQUALTO, BEGIN, COMMIT, ROLLBACK, END"
finally:
line = sys.stdin.readline().rstrip()