feat(minor): add before_commit methods
This commit is contained in:
parent
56bc0d9efd
commit
9887fcef7c
2 changed files with 7 additions and 0 deletions
|
|
@ -148,6 +148,7 @@ def init(site, sites_path=None, new_site=False):
|
|||
"new_site": new_site
|
||||
})
|
||||
local.rollback_observers = []
|
||||
local.before_commit = []
|
||||
local.test_objects = {}
|
||||
|
||||
local.site = site
|
||||
|
|
|
|||
|
|
@ -746,6 +746,9 @@ class Database(object):
|
|||
|
||||
def commit(self):
|
||||
"""Commit current transaction. Calls SQL `COMMIT`."""
|
||||
for method in frappe.local.before_commit:
|
||||
frappe.call(method[0], *(method[1] or []), **(method[2] or {}))
|
||||
|
||||
self.sql("commit")
|
||||
|
||||
frappe.local.rollback_observers = []
|
||||
|
|
@ -753,6 +756,9 @@ class Database(object):
|
|||
enqueue_jobs_after_commit()
|
||||
flush_local_link_count()
|
||||
|
||||
def add_before_commit(self, method, args=None, kwargs=None):
|
||||
frappe.local.before_commit.append([method, args, kwargs])
|
||||
|
||||
@staticmethod
|
||||
def flush_realtime_log():
|
||||
for args in frappe.local.realtime_log:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue