How to use the transaction.get function in transaction

To help you get started, we’ve selected a few transaction examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mgedmin / zodbbrowser / src / zodbbrowser / ftests / test_standalone.py View on Github external
def createTestDataForBrowsing(cls, root_folder):
        # set up data that browsing.txt expects
        root_folder['browsing'] = Folder()
        transaction.get().note(u"createTestDataForBrowsing")
        transaction.commit()
github ipython / ipython / IPython / deathrow / ipy_profile_zope.py View on Github external
def commit(self):
        """
        Commit the transaction.
        """
        try:
            import transaction
            transaction.get().commit()
        except ImportError:
            get_transaction().commit()
github enkore / borgcube / src / borgcube / job / backup.py View on Github external
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
github cguardia / ZODB-Documentation / code / transaction / todo_single_file / todo.py View on Github external
def __init__(self, request):
        self.request = request
        self.dm = PickleDataManager()
        t = transaction.get()
        t.join(self.dm)
github castlecms / castle.cms / castle / cms / audit.py View on Github external
# 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
github plomino / Plomino / Products / CMFPlomino / PlominoDesignManager.py View on Github external
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:
github collective / collective.taskqueue / src / collective / taskqueue / taskqueue.py View on Github external
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
github zopefoundation / Zope / src / Shared / DC / ZRDB / THUNK.py View on Github external
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
github plone / Plone / Products / CMFPlone / patches / sendmail.py View on Github external
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)
github Nexedi / erp5 / product / CMFActivity / ActivityBuffer.py View on Github external
def _register(self, activity_tool):
    TM._register(self)
    if self.activity_tool is None:
      self.activity_tool = activity_tool
      transaction.get().addBeforeCommitHook(self._prepare)