Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def createTestDataForBrowsing(cls, root_folder):
# set up data that browsing.txt expects
root_folder['browsing'] = Folder()
transaction.get().note(u"createTestDataForBrowsing")
transaction.commit()
def commit(self):
"""
Commit the transaction.
"""
try:
import transaction
transaction.get().commit()
except ImportError:
get_transaction().commit()
def client_cleanup(self):
self.job.update_state(BackupJob.State.client_done, BackupJob.State.client_cleanup)
del self.job.client_manifest_data
del self.job.client_manifest_id_str
try:
del self.job.client_key_data
del self.job.client_key_type
except AttributeError:
pass
transaction.get().note('Deleted client keys of job %s' % self.job.id)
transaction.commit()
# TODO delete checkpoints
def __init__(self, request):
self.request = request
self.dm = PickleDataManager()
t = transaction.get()
t.join(self.dm)
# we don't want to record transition events for trashing
# and we want a special psuedo trash event
# then, we still want an event when it gets deleted for good
if iface not in (IAfterTransitionEvent, IObjectRemovedEvent):
# dive out if not IAfterTransitionEvent or object removed event
return
if iface == IObjectRemovedEvent:
audit_data = _registered[iface]
else:
audit_data = _registered[ITrashed]
else:
audit_data = _registered[iface]
recorder = audit_data.get_recorder(event, obj)
site_path = '/'.join(api.portal.get().getPhysicalPath())
transaction.get().addAfterCommitHook(record, args=(
recorder, site_path, ESConnectionFactoryFactory(registry)))
else:
pass
def importDesignFromZip(self, zip_file, replace=False):
"""Import the design from a zip file
"""
logger.info("Start design import")
self.setStatus("Importing design")
self.getIndex().no_refresh = True
txn = transaction.get()
count = 0
total = 0
if replace:
logger.info("Replace mode: removing current design")
designelements = (
[o.id for o in self.getForms()] +
[o.id for o in self.getViews()] +
[o.id for o in self.getAgents()])
ObjectManager.manage_delObjects(self, designelements)
ObjectManager.manage_delObjects(
self.resources,
list(self.resources.objectIds()))
logger.info("Current design removed")
total_elements = None
file_names = zip_file.namelist()
for file_name in file_names:
def add(self, url=None, method='GET', params=None, headers=None,
payload=_marker):
task_id, task = make_task(url, method, params, headers, payload)
get_transaction().join(self.transaction_data_manager(self, task))
return task_id
def _register(self):
if not self._registered:
thunk_lock.acquire()
try:
transaction.get().register(Surrogate(self))
self._begin()
except:
thunk_lock.release()
raise
else:
self._registered=1
def _catch(*args, **kwargs):
try:
return func(*args, **kwargs)
except Exception as e:
txn = transaction.get()
if txn.status == Status.ACTIVE:
# sent with immediate=True
raise
else:
# Avoid raising errors during tpc_finish as these could lead to
# inconsistent state
log.exception(e)
def _register(self, activity_tool):
TM._register(self)
if self.activity_tool is None:
self.activity_tool = activity_tool
transaction.get().addBeforeCommitHook(self._prepare)