summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/events.py
Commit message (Collapse)AuthorAgeFilesLines
* Replace all http:// links to https://Federico Caselli2021-07-041-1/+1
| | | | | | Also replace http://pypi.python.org/pypi with https://pypi.org/project Change-Id: I84b5005c39969a82140706472989f2a30b0c7685
* Ignore flake8 F401 on specific filesFederico Caselli2021-03-031-5/+5
| | | | | | | | Uses the flake8 option per-file-ignores that was introduced in a recent version of flake8 (3.7.+) to avoid having lots of "noqa" in import only files Change-Id: Ib4871d63bad7e578165615df139cbf6093479201
* happy new yearMike Bayer2021-01-041-1/+1
| | | | Change-Id: Ic5bb19ca8be3cb47c95a0d3315d84cb484bac47c
* Reorganize core event modules to avoid import cyclesMike Bayer2020-01-211-1285/+5
| | | | | | | | | sqlalchemy.sql.naming was causing a full import of engine due to the DDLEvents dependency. Break out pool, DDL and engine events into new modules specific to those packages; resolve some other import cycles in Core also. Change-Id: Ife8d217e58a26ab3605dd80ee70837968f957eaf
* happy new yearMike Bayer2020-01-011-1/+1
| | | | Change-Id: I08440dc25e40ea1ccea1778f6ee9e28a00808235
* Add deprecation warnings to all deprecated APIsMike Bayer2019-01-231-5/+8
| | | | | | | | | | | | | | | 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
* Convert most "See also" phrases into .. seealso::Mike Bayer2019-01-151-7/+6
| | | | | Change-Id: Ie32598b895c1c5f5bce7c8e1573abbcfe9d434a8 (cherry picked from commit e81d3815abb36c52b0019dee6e4f67990e3d1c7d)
* Remove version directives for 0.6, 0.7, 0.8Mike Bayer2019-01-151-6/+0
| | | | | | | | | - fix a few "seealso"s - ComparableProprerty's "superseded in 0.7" becomes deprecated in 0.7 Backport to currently maintained doc versions 1.2, 1.1 Change-Id: Ib1fcb2df8673dbe5c4ffc47f3896a60d1dfcb4b2
* Merge "use ..deprecated directive w/ version in all cases"mike bayer2019-01-121-2/+4
|\
| * use ..deprecated directive w/ version in all casesMike Bayer2019-01-111-2/+4
| | | | | | | | | | | | | | | | | | 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-111-1/+1
|/ | | | Change-Id: I6a71f4924d046cf306961c58dffccf21e9c03911
* Post black reformattingMike Bayer2019-01-061-12/+12
| | | | | | | | | | | | | 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-061-26/+48
| | | | | | | | | | | | | | 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 do_setinputsizes event for cx_OracleMike Bayer2018-06-271-0/+38
| | | | | | | | | | | | | Added a new event currently used only by the cx_Oracle dialect, :meth:`.DialectEvents.setiputsizes`. The event passes a dictionary of :class:`.BindParameter` objects to DBAPI-specific type objects that will be passed, after conversion to parameter names, to the cx_Oracle ``cursor.setinputsizes()`` method. This allows both visibility into the setinputsizes process as well as the ability to alter the behavior of what datatypes are passed to this method. Change-Id: I43b97c8e3c840cad6f01edb274dc9cfed19cb5fc Fixes: #4290
* - ensure it's clear that all DDLEvents can be associatedMike Bayer2018-02-021-12/+58
| | | | | | | using propagate=True, which is consulted within the scope of Table.tometadata(). Fixes: #4179 Change-Id: I0cb0d8f6a894bb645cfc94b3d9083339039c9193
* happy new yearMike Bayer2018-01-121-1/+1
| | | | Change-Id: I3ef36bfd0cb0ba62b3123c8cf92370a43156cf8f
* - tweak the handle_error docs a bitMike Bayer2017-09-281-4/+21
| | | | Change-Id: Iebe5b13b3a568f3aa0f3ab02a55e2a9cbb4545c7
* Fixed a typo in before_execute doc.Michael Smirnov2017-08-221-1/+1
| | | events.py edited online with Bitbucket
* Accept FetchedValue, text() for column "default" valueMike Bayer2017-02-011-1/+23
| | | | | | | | | | | | | Fixed bug whereby the :meth:`.DDLEvents.column_reflect` event would not allow a non-textual expression to be passed as the value of the "default" for the new column, such as a :class:`.FetchedValue` object to indicate a generic triggered default or a :func:`.sql.expression.text` construct. Clarified the documentation in this regard as well. Fixes: #3905 Change-Id: I829796c3e9f87f375149bebee7eef133a6876d4d
* Support python3.6Mike Bayer2017-01-131-7/+7
| | | | | | | | | | | Corrects some warnings and adds tox config. Adds DeprecationWarning to the error category. Large sweep for string literals w/ backslashes as this is common in docstrings Co-authored-by: Andrii Soldatenko Fixes: #3886 Change-Id: Ia7c838dfbbe70b262622ed0803d581edc736e085 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/337
* update for 2017 copyrightMike Bayer2017-01-041-1/+1
| | | | Change-Id: I4e8c2aa8fe817bb2af8707410fa0201f938781de
* Handle BaseException in all _handle_dbapi_errorMike Bayer2016-09-211-0/+10
| | | | | | | | | | | | | | | | | Tests illustrate that exceptions like GreenletExit and even KeyboardInterrupt can corrupt the state of a DBAPI connection like that of pymysql and mysqlclient. Intercept BaseException errors within the handle_error scheme and invalidate just the connection alone in this case, but not the whole pool. The change is backwards-incompatible with a program that currently intercepts ctrl-C within a database transaction and wants to continue working on that transaction. Ensure the event hook can be used to reverse this behavior. Change-Id: Ifaa013c13826d123eef34e32b7e79fff74f1b21b Fixes: #3803
* Let logging format messages on demand, use warning instead of deprecated warnpr/265Ville Skyttä2016-05-031-2/+2
|
* - Added connection pool events :meth:`ConnectionEvents.close`,Mike Bayer2016-03-251-0/+40
| | | | | :meth:`.ConnectionEvents.detach`, :meth:`.ConnectionEvents.close_detached`.
* - happy new yearMike Bayer2016-01-291-1/+1
|
* - update the pool pessimistic invalidation recipe to refer to theMike Bayer2015-10-221-0/+5
| | | | | engine_connect event, allowing easy detection of disconnects and full invalidation of the pool
* - Added new engine event :meth:`.ConnectionEvents.engine_disposed`.Mike Bayer2015-06-061-0/+17
| | | | Called after the :meth:`.Engine.dispose` method is called.
* - New features added to support engine/pool plugins with advancedMike Bayer2015-04-301-1/+45
| | | | | | | | | | | | | | | | | | | | | | | | | functionality. Added a new "soft invalidate" feature to the connection pool at the level of the checked out connection wrapper as well as the :class:`._ConnectionRecord`. This works similarly to a modern pool invalidation in that connections aren't actively closed, but are recycled only on next checkout; this is essentially a per-connection version of that feature. A new event :class:`.PoolEvents.soft_invalidate` is added to complement it. fixes #3379 - Added new flag :attr:`.ExceptionContext.invalidate_pool_on_disconnect`. Allows an error handler within :meth:`.ConnectionEvents.handle_error` to maintain a "disconnect" condition, but to handle calling invalidate on individual connections in a specific manner within the event. - Added new event :class:`.DialectEvents.do_connect`, which allows interception / replacement of when the :meth:`.Dialect.connect` hook is called to create a DBAPI connection. Also added dialect plugin hooks :meth:`.Dialect.get_dialect_cls` and :meth:`.Dialect.engine_created` which allow external plugins to add events to existing dialects using entry points. fixes #3355
* - copyright 2015Mike Bayer2015-03-101-1/+1
|
* - The engine-level error handling and wrapping routines will nowMike Bayer2014-12-051-0/+6
| | | | | | | | | take effect in all engine connection use cases, including when user-custom connect routines are used via the :paramref:`.create_engine.creator` parameter, as well as when the :class:`.Connection` encounters a connection error on revalidation. fixes #3266
* Merged in jvanasco/sqlalchemy-alt/issue_docs_event_statement (pull request #33) Mike Bayer2014-11-261-6/+11
|\ | | | | added docs to clarify that sql statement is already in a dialect
| * added docs to clarify that sql statement is already in a dialectjonathan vanasco2014-10-171-6/+11
| |
* | changed connnection to connectionpr/146jlgoldb22014-10-261-1/+1
|/
* - Fixed bug that affected generally the same classes of eventMike Bayer2014-09-181-1/+2
| | | | | | | | | | 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
* - The MySQL dialect will now disable :meth:`.ConnectionEvents.handle_error`Mike Bayer2014-07-251-0/+10
| | | | | | | | | | events from firing for those statements which it uses internally to detect if a table exists or not. This is achieved using an execution option ``skip_user_error_events`` that disables the handle error event for the scope of that execution. In this way, user code that rewrites exceptions doesn't need to worry about the MySQL dialect or other dialects that occasionally need to catch SQLAlchemy specific exceptions.
* PEP8 style fixesBrian Jarrett2014-07-131-30/+30
|
* - break up the <authors> copyright comment as part of a passMike Bayer2014-07-091-1/+2
| | | | to get all flake8 passing
* - rework the entire approach to #3076. As we need to catch all exceptionsMike Bayer2014-07-041-40/+79
| | | | | | | | | | | in all cases unconditionally, the number of use cases that go beyond what dbapi_error() is expecting has gone too far for an 0.9 release. Additionally, the number of things we'd like to track is really a lot more than the five arguments here, and ExecutionContext is really not suitable as totally public API for this. So restore dbapi_error to its old version, deprecate, and build out handle_error instead. This is a lot more extensible and doesn't get in the way of anything compatibility-wise.
* - The mechanics of the :meth:`.ConnectionEvents.dbapi_error` handlerMike Bayer2014-07-031-18/+67
| | | | | | | have been enhanced such that the function handler is now capable of raising or returning a new exception object, which will replace the exception normally being thrown by SQLAlchemy. fixes #3076
* Fix many typos throughout the codebasepr/85Alex Gaynor2014-04-261-6/+6
| | | | Found using: https://github.com/intgr/topy
* - Added some new event mechanics for dialect-level events; the initialMike Bayer2014-03-241-1/+83
| | | | | | | implementation allows an event handler to redefine the specific mechanics by which an arbitrary dialect invokes execute() or executemany() on a DBAPI cursor. The new events, at this point semi-public and experimental, are in support of some upcoming transaction-related extensions.
* - add new event PoolEvents.invalidate(). allows interception of invalidationMike Bayer2014-01-121-28/+61
| | | | | | | | | | | | | | | events including auto-invalidation, which is useful both for tests here as well as detecting failure conditions within the "reset" or "close" cases. - rename the argument for PoolEvents.reset() to dbapi_connection and connection_record to be consistent with everything else. - add new documentation sections on invalidation, including auto-invalidation and the invalidation process within the pool. - add _ConnectionFairy and _ConnectionRecord to the pool documentation. Establish docs for common _ConnectionFairy/_ConnectionRecord methods and accessors and have PoolEvents docs refer to _ConnectionRecord, since it is passed to all events. Rename a few _ConnectionFairy methods that are actually private to pool such as _checkout(), _checkin() and _checkout_existing(); there should not be any external code calling these
* - happy new yearMike Bayer2014-01-051-1/+1
|
* Fix cross referencesVraj Mohan2013-11-171-1/+1
|
* Fix method nameVraj Mohan2013-11-141-2/+2
|
* - apply an import refactoring to the ORM as wellMike Bayer2013-08-141-30/+13
| | | | | | | | | - 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
* - A large refactoring of the ``sqlalchemy.sql`` package has reorganizedMike Bayer2013-08-121-3/+5
| | | | | | | | | | | | | | | | | | | | | | the import structure of many core modules. ``sqlalchemy.schema`` and ``sqlalchemy.types`` remain in the top-level package, but are now just lists of names that pull from within ``sqlalchemy.sql``. Their implementations are now broken out among ``sqlalchemy.sql.type_api``, ``sqlalchemy.sql.sqltypes``, ``sqlalchemy.sql.schema`` and ``sqlalchemy.sql.ddl``, the last of which was moved from ``sqlalchemy.engine``. ``sqlalchemy.sql.expression`` is also a namespace now which pulls implementations mostly from ``sqlalchemy.sql.elements``, ``sqlalchemy.sql.selectable``, and ``sqlalchemy.sql.dml``. Most of the "factory" functions used to create SQL expression objects have been moved to classmethods or constructors, which are exposed in ``sqlalchemy.sql.expression`` using a programmatic system. Care has been taken such that all the original import namespaces remain intact and there should be no impact on any existing applications. The rationale here was to break out these very large modules into smaller ones, provide more manageable lists of function names, to greatly reduce "import cycles" and clarify the up-front importing of names, and to remove the need for redundant functions and documentation throughout the expression package.
* - Removal of event listeners is now implemented. The feature isMike Bayer2013-07-261-2/+5
| | | | | | | | | | | | | | | | 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.
* - create a new system where we can decorate an event methodMike Bayer2013-07-081-1/+7
| | | | | | | | | | | | | | | | with @_legacy_signature, will inspect incoming listener functions to see if they match an older signature, will wrap into a newer sig - add an event listen argument named=True, will send all args as kw args so that event listeners can be written with **kw, any combination of names - add a doc system to events that writes out the various calling styles for a given event, produces deprecation messages automatically. a little concerned that it's a bit verbose but will look at it up on RTD for awhile to get a feel. - change the calling signature for bulk update/delete events - we have the BulkUD object right there, and there's at least six or seven things people might want to see, so just send the whole BulkUD in [ticket:2775]
* - refactor pool a bit so that intent between ↵Mike Bayer2013-07-021-0/+101
| | | | | | | | | | | | | | ConnectionRecord/ConnectionFairy is clear; make sure that the DBAPI connection passed to the reset-on-return events/dialect hooks is also a "fairy", so that dictionaries like "info" are available. [ticket:2770] - rework the execution_options system so that the dialect is given the job of making any immediate adjustments based on a set event. move the "isolation level" logic to use this new system. Also work things out so that even engine-level execution options can be used for things like isolation level; the dialect attaches a connect-event handler in this case to handle the task. - to support this new system as well as further extensibiltiy of execution options add events engine_connect(), set_connection_execution_options(), set_engine_execution_options()