summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/event
Commit message (Collapse)AuthorAgeFilesLines
* Fix a wide variety of typos and broken linksaplatkouski2020-06-252-3/+3
| | | | | | | | | | | | Note the PR has a few remaining doc linking issues listed in the comment that must be addressed separately. Signed-off-by: aplatkouski <5857672+aplatkouski@users.noreply.github.com> Closes: #5371 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5371 Pull-request-sha: 7e7d233cf3a0c66980c27db0fcdb3c7d93bc2510 Change-Id: I9c36e8d8804483950db4b42c38ee456e384c59e3
* Create initial 2.0 engine implementationMike Bayer2020-04-162-0/+22
| | | | | | | | | | | | | | | | | | | Implemented the SQLAlchemy 2 :func:`.future.create_engine` function which is used for forwards compatibility with SQLAlchemy 2. This engine features always-transactional behavior with autobegin. Allow execution options per statement execution. This includes that the before_execute() and after_execute() events now accept an additional dictionary with these options, empty if not passed; a legacy event decorator is added for backwards compatibility which now also emits a deprecation warning. Add some basic tests for execution, transactions, and the new result object. Build out on a new testing fixture that swaps in the future engine completely to start with. Change-Id: I70e7338bb3f0ce22d2f702537d94bb249bd9fb0a Fixes: #4644
* Remove return statement in __init__.Heckad2020-01-041-1/+1
|
* happy new yearMike Bayer2020-01-016-6/+6
| | | | Change-Id: I08440dc25e40ea1ccea1778f6ee9e28a00808235
* Add new "exec_once_unless_exception" system; apply to dialect.initializeMike Bayer2019-08-182-11/+39
| | | | | | | | | | | | | | | | | | Fixed an issue whereby if the dialect "initialize" process which occurs on first connect would encounter an unexpected exception, the initialize process would fail to complete and then no longer attempt on subsequent connection attempts, leaving the dialect in an un-initialized, or partially initialized state, within the scope of parameters that need to be established based on inspection of a live connection. The "invoke once" logic in the event system has been reworked to accommodate for this occurrence using new, private API features that establish an "exec once" hook that will continue to allow the initializer to fire off on subsequent connections, until it completes without raising an exception. This does not impact the behavior of the existing ``once=True`` flag within the event system. Fixes: #4807 Change-Id: Iec32999b61b6af4b38b6719e0c2651454619078c
* Strong reference listen function wrapped by "once"Mike Bayer2019-08-041-0/+14
| | | | | | | | | | | | | | Fixed issue in event system where using the ``once=True`` flag with dynamically generated listener functions would cause event registration of future events to fail if those listener functions were garbage collected after they were used, due to an assumption that a listened function is strongly referenced. The "once" wrapped is now modified to strongly reference the inner function persistently, and documentation is updated that using "once" does not imply automatic de-registration of listener functions. Fixes: #4794 Change-Id: I06388083d1633dcc89e8919eb1e51270f966df38
* Add deprecation warnings to all deprecated APIsMike Bayer2019-01-232-0/+10
| | | | | | | | | | | | | | | A large change throughout the library has ensured that all objects, parameters, and behaviors which have been noted as deprecated or legacy now emit ``DeprecationWarning`` warnings when invoked. As the Python 3 interpreter now defaults to displaying deprecation warnings, as well as that modern test suites based on tools like tox and pytest tend to display deprecation warnings, this change should make it easier to note what API features are obsolete. See the notes added to the changelog and migration notes for further details. Fixes: #4393 Change-Id: If0ea11a1fc24f9a8029352eeadfc49a7a54c0a1b
* move to inspect_getfullargspecMike Bayer2019-01-152-5/+6
| | | | | | | | Replace inspect_getargspec with inspect_getfullargspec including a compatibility fallback for Py2k and use getfullargspec fully. Change-Id: I92bce0aafc37ce1a360b4f61b75f5892d0911c7e
* Merge "use ..deprecated directive w/ version in all cases"mike bayer2019-01-122-8/+17
|\
| * use ..deprecated directive w/ version in all casesMike Bayer2019-01-112-8/+17
| | | | | | | | | | | | | | | | | | These changes should be ported from 1.3 back to 1.0 or possibly 0.9 to the extent they are relevant in each version. In 1.3 we hope to turn all deprecation documentation into warnings. Change-Id: I205186cde161af9389af513a425c62ce90dd54d8
* | happy new yearMike Bayer2019-01-116-6/+6
|/ | | | Change-Id: I6a71f4924d046cf306961c58dffccf21e9c03911
* Post black reformattingMike Bayer2019-01-065-19/+31
| | | | | | | | | | | | | Applied on top of a pure run of black -l 79 in I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9, this set of changes resolves all remaining flake8 conditions for those codes we have enabled in setup.cfg. Included are resolutions for all remaining flake8 issues including shadowed builtins, long lines, import order, unused imports, duplicate imports, and docstring issues. Change-Id: I4f72d3ba1380dd601610ff80b8fb06a2aff8b0fe
* Run black -l 79 against all source filesMike Bayer2019-01-065-108/+153
| | | | | | | | | | | | | | This is a straight reformat run using black as is, with no edits applied at all. The black run will format code consistently, however in some cases that are prevalent in SQLAlchemy code it produces too-long lines. The too-long lines will be resolved in the following commit that will resolve all remaining flake8 issues including shadowed builtins, long lines, import order, unused imports, duplicate imports, and docstring issues. Change-Id: I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9
* Add before_mapper_configured eventChris Wilson2018-12-101-1/+1
| | | | | | | | | | | | | | | | This event is intended to allow a specific mapper to be skipped during the configure step, by returning a value of `.orm.interfaces.EXT_SKIP` which means the mapper will be skipped within this configure run. The "new mappers" flag will remain set in this case and the configure operation will occur again. This event, and its return value, make it possible to query one base while a different one still needs configuration, which cannot be completed at this time. Fixes: #4397 Change-Id: I122e556f6a4ff842ad15315dcf39e19bb7f9a744 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4403
* Tweak code-style and readability in `events/base.py`Iwo Herka2018-11-021-42/+38
| | | | | | | | | This includes a few low-key, syntax-level tweaks and: 1. Rewrite of the if-statment in `Events._accept_with`. 2. Property name change, i.e. from `dispatcher.dispatch_cls` to `dispatcher.dispatch`. In this case postfix `_cls` is confusing as the property is not a class, but an instance of one.
* Implement remove() for _empty_collectionMike Bayer2018-02-191-0/+3
| | | | | | | | | | | Fixed regression caused in 1.2.3 due to fix from :ticket:`4181` where the changes to the event system involving :class:`.Engine` and :class:`.OptionEngine` did not accommodate for event removals, which would raise an ``AttributeError`` when invoked at the class level. Change-Id: I1c9083829d74dd710716d28b0eaca4fa15e86313 Fixes: #4190
* Add flag for class-level disallow of events, apply to OptionEngineMike Bayer2018-02-071-5/+30
| | | | | | | | | | | | | | | | | | | | Fixed bug where events associated with an :class:`Engine` at the class level would be doubled when the :meth:`.Engine.execution_options` method were used. To achieve this, the semi-private class :class:`.OptionEngine` no longer accepts events directly at the class level and will raise an error; the class only propagates class-level events from its parent :class:`.Engine`. Instance-level events continue to work as before. The comments present another way of doing this where we would copy events from the parent engine at option time rather than linking the event listeners, but this would be a behavioral change that adding new events to the parent engine would not take effect for an already-created OptionEngine. Change-Id: Id128516f54103fbad9a2210d6571eceb59c8b0cb Fixes: #4181
* happy new yearMike Bayer2018-01-126-6/+6
| | | | Change-Id: I3ef36bfd0cb0ba62b3123c8cf92370a43156cf8f
* update for 2017 copyrightMike Bayer2017-01-046-6/+6
| | | | Change-Id: I4e8c2aa8fe817bb2af8707410fa0201f938781de
* - happy new yearMike Bayer2016-01-296-6/+6
|
* - Fixed an issue where a particular base class within utilsMike Bayer2015-07-201-7/+7
| | | | | | | | | didn't implement ``__slots__``, and therefore meant all subclasses of that class didn't either, negating the rationale for ``__slots__`` to be in use. Didn't cause any issue except on IronPython which apparently does not implement ``__slots__`` behavior compatibly with cPython. Fixes #3494
* - copyright 2015Mike Bayer2015-03-106-6/+6
|
* - add MemoizedSlots, a generalized solution to using __getattr__Mike Bayer2015-01-051-12/+13
| | | | | for memoization on a class that uses slots. - apply many more __slots__. mem use for nova now at 46% savings
* - scale back _Dispatch and _JoinedDispatcher to use a __getitem__ schemeMike Bayer2015-01-041-12/+29
| | | | | | to start up listener collections; this pulls the overhead off of construction and makes performance much like the descriptor version, while still allowing slots. Fix up some profiles.
* - wip - start factoring events so that we aren't using descriptors for dispatch,Mike Bayer2015-01-044-124/+155
| | | | allowing us to move to __slots__
* - start trying to move things into __slots__. This seems to reduce theslotsMike Bayer2015-01-043-0/+10
| | | | | size of the many per-column objects we're hitting, but somehow the overall memory is hardly being reduced at all in initial testing
* - Fixed bug that affected generally the same classes of eventMike Bayer2014-09-181-3/+11
| | | | | | | | | | as that of :ticket:`3199`, when the ``named=True`` parameter would be used. Some events would fail to register, and others would not invoke the event arguments correctly, generally in the case of when an event was "wrapped" for adaption in some other way. The "named" mechanics have been rearranged to not interfere with the argument signature expected by internal wrapper functions. fixes #3197
* - Fixed bug that affected many classes of event, particularlyMike Bayer2014-09-182-15/+17
| | | | | | | | | | | ORM events but also engine events, where the usual logic of "de duplicating" a redundant call to :func:`.event.listen` with the same arguments would fail, for those events where the listener function is wrapped. An assertion would be hit within registry.py. This assertion has now been integrated into the deduplication check, with the added bonus of a simpler means of checking deduplication across the board. fixes #3199
* - Removing (or adding) an event listener at the same time that the eventMike Bayer2014-08-143-8/+63
| | | | | | | | | is being run itself, either from inside the listener or from a concurrent thread, now raises a RuntimeError, as the collection used is now an instance of ``colletions.deque()`` and does not support changes while being iterated. Previously, a plain Python list was used where removal from inside the event itself would produce silent failures. fixes #3163
* - apply pep8 formatting to sqlalchemy/sql, sqlalchemy/util, sqlalchemy/dialects,Brian Jarrett2014-07-205-98/+119
| | | | sqlalchemy/orm, sqlalchemy/event, sqlalchemy/testing
* - break up the <authors> copyright comment as part of a passMike Bayer2014-07-096-6/+12
| | | | to get all flake8 passing
* once kwarg in event funcs is new in 0.9.4Justin Wood (Callek)2014-06-051-2/+2
| | | | event.listen and event.listen_for have a kwarg once added in 0.9.4 (not 0.9.3) CHANGELOG agrees with this as well. (as does my manual testing)
* Documentation fix-up: "its" vs. "it's"pr/91Matthias Urlichs2014-05-111-1/+1
| | | | | | | | | Removed ungrammatical apostrophes from documentation, replacing "it's" with "its" where appropriate (but in a few cases with "it is" when that read better). While doing that, I also fixed a couple of minor typos etc. as I noticed them.
* - Added a new keyword argument ``once=True`` to :func:`.event.listen`Mike Bayer2014-03-112-2/+31
| | | | | and :func:`.event.listens_for`. This is a convenience feature which will wrap the given listener such that it is only invoked once.
* - get util.get_callable_argspec() to be completely bulletproof for 2.6-3.4,Mike Bayer2014-03-021-1/+1
| | | | | methods, classes, builtins, functools.partial(), everything known so far - use get_callable_argspec() within ColumnDefault._maybe_wrap_callable, re: #2979
* - Fixed bug where events set to listen at the classMike Bayer2014-02-251-1/+1
| | | | | | | | level (e.g. on the :class:`.Mapper` or :class:`.ClassManager` level, as opposed to on an individual mapped class, and also on :class:`.Connection`) that also made use of internal argument conversion (which is most within those categories) would fail to be removable. fixes #2973
* restore the check ahead of the lock to avoid using it after initializationMike Bayer2014-02-191-6/+7
| | | | is done
* - Fixed a critical regression caused by :ticket:`2880` where the newlyMike Bayer2014-02-191-4/+13
| | | | | | concurrent ability to return connections from the pool means that the "first_connect" event is now no longer synchronized either, thus leading to dialect mis-configurations under even minimal concurrency situations.
* - bump up how many args for "named arg style" to fourMike Bayer2014-01-121-1/+1
|
* - happy new yearMike Bayer2014-01-056-6/+6
|
* - Fixed regression where using a ``functools.partial()`` with the eventMike Bayer2014-01-041-2/+7
| | | | | | | | | | | system would cause a recursion overflow due to usage of inspect.getargspec() on it in order to detect a legacy calling signature for certain events, and apparently there's no way to do this with a partial object. Instead we skip the legacy check and assume the modern style; the check itself now only occurs for the SessionEvents.after_bulk_update and SessionEvents.after_bulk_delete events. Those two events will require the new signature style if assigned to a "partial" event listener. [ticket:2905]
* - add copyright to source files missing itMike Bayer2013-10-266-1/+31
|
* - add support for removal of instance methods as event listeners, takingMike Bayer2013-10-011-2/+6
| | | | into account the id() of the function itself and self, [ticket:2832]
* - apply an import refactoring to the ORM as wellMike Bayer2013-08-143-21/+44
| | | | | | | | | - rework the event system so that event modules load after their targets, dependencies are reversed - create an improved strategy lookup system for the ORM - rework the ORM to have very few import cycles - move out "importlater" to just util.dependency - other tricks to cross-populate modules in as clear a way as possible
* fix missing commaMike Bayer2013-07-311-1/+1
|
* - this collection can be None on cleanup, so check for thatMike Bayer2013-07-271-1/+1
|
* - add event.contains() function to the event package, returns TrueMike Bayer2013-07-263-17/+23
| | | | | if the given target/event/fn is set up to listen. - repair mutable package which is doing some conditional event listening
* - Removal of event listeners is now implemented. The feature isMike Bayer2013-07-266-0/+1034
provided via the :func:`.event.remove` function. [ticket:2268] - reorganization of event.py module into a package; with the addition of the docstring work as well as the new registry for removal, there's a lot more code now. the package separates concerns and provides a top-level doc for each subsection of functionality - the remove feature works by providing the EventKey object which associates the user-provided arguments to listen() with a global, weak-referencing registry. This registry stores a collection of _ListenerCollection and _DispatchDescriptor objects associated with each set of arguments, as well as the wrapped function which was applied to that collection. The EventKey can then be recreated for a removal, all the _ListenerCollection and _DispatchDescriptor objects are located, and the correct wrapped function is removed from each one.