Xavier Morel c853eb5a37 [IMP] core: savepoint semantics and interface
Ensure savepoints are *always* released when exiting the context:
rolling back to a savepoint does not release it, so the savepoint
would remain "active" forever (just possibly shadowed).

Also provide a `Savepoint` object to the user, with the following
facilities:

* `name`, in case there are useful things the user can do with a
  savepoint name.

  The name uses standard UUID representation (rather
  than pure hex) because it's otherwise difficult to differentiate
  savepoints: in a UUID1, fields 2, 3, and 5 almost certainly don't
  change, and the changes between two UUIDs are the last 2-3 nibbles
  of field 1 (`time_low`) and the content of field 4 (`seq`, 4 nibbles
  at offset 16), with "properly" separated fields it's much easier to
  notice the difference.
* `rollback` allows the user to rollback the savepoint to the
  initialisation state at any moment.
* `close` allows the use of `contextlib.closing` as well as closing
  the savepoint while in the covered span. Closing a savepoint rolls
  it back by default (like cursors).

  Because there's no such thing as committing a savepoint, it's also
  possible to close *without* rolling back, which is similar (but not
  identical).

  This requires using the semantics of emitting the `SAVEPOINT` during
  object initialisation: `closing` was designed to work with non-CMs so
  it does not forward `__enter__` to the wrapped object.

Also introduce a CM type for the flushing:

* `_GeneratorContextManager` does not work well when used outside of a
  `with`, especially when it yields something: if the CM itself goes
  out of scope, the inner generator is `close`d, which raises a
  `GeneratorExit` at the `yield` point, which `__exit__`s whichever CM
  is held (and in our case would thus rollback and release the
  savepoint)
* we probably want to clear() on `rollback`, so having the flushing CM
  extend the savepoint one makes a lot of sense
* while it changes the semantics of `Cursor.savepoint` a bit (now
  initialises the savepoint at call time instead of delaying until
  `__enter__`), it enables the use of `closing` with flushing, and
  without having to use the context manager objects directly:
  `Cursor.savepoint()` is the only necessary interface, and should
  work fine with and without flushing.

Part-of: odoo/odoo#76243
2021-10-01 15:26:50 +00:00
2021-09-16 07:17:40 +00:00
…
…
…
…
2020-09-28 14:07:25 +00:00

Build Status Tech Doc Help Nightly Builds

Odoo

Odoo is a suite of web based open source business apps.

The main Odoo Apps include an Open Source CRM, Website Builder, eCommerce, Warehouse Management, Project Management, Billing & Accounting, Point of Sale, Human Resources, Marketing, Manufacturing, ...

Odoo Apps can be used as stand-alone applications, but they also integrate seamlessly so you get a full-featured Open Source ERP when you install several Apps.

Getting started with Odoo

For a standard installation please follow the Setup instructions from the documentation.

To learn the software, we recommend the Odoo eLearning, or Scale-up, the business game. Developers can start with the developer tutorials

S
Description
No description provided
Readme LGPL-3.0
3.4 GiB
Languages
Python 49.6%
JavaScript 47.8%
SCSS 2%
CSS 0.3%
HTML 0.2%