summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/events.py
Commit message (Collapse)AuthorAgeFilesLines
* - The :class:`.SessionEvents` suite now includes events to allowticket_2677Mike Bayer2015-09-021-0/+240
| | | | | | | | | | | | | | | | | | | | | unambiguous tracking of all object lifecycle state transitions in terms of the :class:`.Session` itself, e.g. pending, transient, persistent, detached. The state of the object within each event is also defined. fixes #2677 - Added a new session lifecycle state :term:`deleted`. This new state represents an object that has been deleted from the :term:`persistent` state and will move to the :term:`detached` state once the transaction is committed. This resolves the long-standing issue that objects which were deleted existed in a gray area between persistent and detached. The :attr:`.InstanceState.persistent` accessor will **no longer** report on a deleted object as persistent; the :attr:`.InstanceState.deleted` accessor will instead be True for these objects, until they become detached. - The :paramref:`.Session.weak_identity_map` parameter is deprecated. See the new recipe at :ref:`session_referencing_behavior` for an event-based approach to maintaining strong identity map behavior. references #3517
* - add new documentation that applies to all modern SQLA versions,ticket_2677_preMike Bayer2015-09-021-140/+83
| | | | detailing ORM event recipes across the board.
* - re-document and fully cross link all of configure_mappers(),Mike Bayer2015-08-241-19/+84
| | | | mapper_configured(), after_configured(), and before_configured().
* - add tests for InstanceEvents.init, InstanceEvents.init_failureMike Bayer2015-08-141-4/+67
| | | | | | | - ensure that kwargs can be modified in-place within InstanceEvents.init and that these take effect for the __init__ method. - improve documentation for these and related events, including that kwargs can be modified in-place.
* - Fixed regression in the :mod:`sqlalchemy.ext.mutable` extensionMike Bayer2015-05-211-2/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | as a result of the bugfix for :ticket:`3167`, where attribute and validation events are no longer called within the flush process. The mutable extension was relying upon this behavior in the case where a column level Python-side default were responsible for generating the new value on INSERT or UPDATE, or when a value were fetched from the RETURNING clause for "eager defaults" mode. The new value would not be subject to any event when populated and the mutable extension could not establish proper coercion or history listening. A new event :meth:`.InstanceEvents.refresh_flush` is added which the mutable extension now makes use of for this use case. fixes #3427 - Added new event :meth:`.InstanceEvents.refresh_flush`, invoked when an INSERT or UPDATE level default value fetched via RETURNING or Python-side default is invoked within the flush process. This is to provide a hook that is no longer present as a result of :ticket:`3167`, where attribute and validation events are no longer called within the flush process. - Added a new semi-public method to :class:`.MutableBase` :meth:`.MutableBase._get_listen_keys`. Overriding this method is needed in the case where a :class:`.MutableBase` subclass needs events to propagate for attribute keys other than the key to which the mutable type is associated with, when intercepting the :meth:`.InstanceEvents.refresh` or :meth:`.InstanceEvents.refresh_flush` events. The current example of this is composites using :class:`.MutableComposite`.
* - Added a new event suite :class:`.QueryEvents`. TheMike Bayer2015-03-101-1/+54
| | | | | | | | | | | :meth:`.QueryEvents.before_compile` event allows the creation of functions which may place additional modifications to :class:`.Query` objects before the construction of the SELECT statement. It is hoped that this event be made much more useful via the advent of a new inspection system that will allow for detailed modifications to be made against :class:`.Query` objects in an automated fashion. fixes #3317
* - copyright 2015Mike Bayer2015-03-101-1/+1
|
* - wip - start factoring events so that we aren't using descriptors for dispatch,Mike Bayer2015-01-041-1/+2
| | | | allowing us to move to __slots__
* - Fixed bug that affected generally the same classes of eventMike Bayer2014-09-181-4/+8
| | | | | | | | | | 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
* - Added new event handlers :meth:`.AttributeEvents.init_collection`Mike Bayer2014-09-071-0/+53
| | | | | | | and :meth:`.AttributeEvents.dispose_collection`, which track when a collection is first associated with an instance and when it is replaced. These handlers supersede the :meth:`.collection.linker` annotation. The old hook remains supported through an event adapter.
* - major refactoring/inlining to loader.instances(), though not reallyMike Bayer2014-08-281-139/+0
| | | | | | | | | | | any speed improvements :(. code is in a much better place to be run into C, however - The ``proc()`` callable passed to the ``create_row_processor()`` method of custom :class:`.Bundle` classes now accepts only a single "row" argument. - Deprecated event hooks removed: ``populate_instance``, ``create_instance``, ``translate_row``, ``append_result`` - the getter() idea is somewhat restored; see ref #3175
* - The "resurrect" ORM event has been removed. This event hook hadMike Bayer2014-08-251-12/+0
| | | | | | no purpose since the old "mutable attribute" system was removed in 0.8. fixes #3171
* - apply pep8 formatting to sqlalchemy/sql, sqlalchemy/util, sqlalchemy/dialects,Brian Jarrett2014-07-201-56/+71
| | | | sqlalchemy/orm, sqlalchemy/event, sqlalchemy/testing
* - break up the <authors> copyright comment as part of a passMike Bayer2014-07-091-1/+2
| | | | to get all flake8 passing
* typo: s/tranasction/transactionPriit Laes2014-06-281-1/+1
|
* - mark translate_row, create_instance, populate_instance, append_result as ↵Mike Bayer2014-05-231-3/+22
| | | | legacy
* Documentation fix-up: "its" vs. "it's"pr/91Matthias Urlichs2014-05-111-3/+3
| | | | | | | | | 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.
* Fix many typos throughout the codebasepr/85Alex Gaynor2014-04-261-3/+3
| | | | Found using: https://github.com/intgr/topy
* - Added support for the not-quite-yet-documented ``insert=True``Mike Bayer2014-03-161-10/+10
| | | | flag for :func:`.event.listen` to work with mapper / instance events.
* - A warning is emitted if the :meth:`.MapperEvents.before_configured`Mike Bayer2014-03-111-2/+46
| | | | | | or :meth:`.MapperEvents.after_configured` events are applied to a specific mapper or mapped class, as the events are only invoked for the :class:`.Mapper` target at the general level.
* - Fixed bug where :class:`.AbstractConcreteBase` would fail to beMike Bayer2014-02-111-0/+17
| | | | | | | | | | | | | | | | | | | | | fully usable within declarative relationship configuration, as its string classname would not be available in the registry of classnames at mapper configuration time. The class now explicitly adds itself to the class regsitry, and additionally both :class:`.AbstractConcreteBase` as well as :class:`.ConcreteBase` set themselves up *before* mappers are configured within the :func:`.configure_mappers` setup, using the new :meth:`.MapperEvents.before_configured` event. [ticket:2950] - Added new :meth:`.MapperEvents.before_configured` event which allows an event at the start of :func:`.configure_mappers`, as well as ``__declare_first__()`` hook within declarative to complement ``__declare_last__()``. - modified how after_configured is invoked; we just make a dispatch() not actually connected to any mapper. this makes it easier to also invoke before_configured correctly. - improved the ComparableEntity fixture to handle collections that are sets.
* - Fixed an 0.9 regression where ORM instance or mapper events appliedMike Bayer2014-02-091-18/+12
| | | | | | | | to a base class such as a declarative base with the propagate=True flag would fail to apply to existing mapped classes which also used inheritance due to an assertion. Addtionally, repaired an attribute error which could occur during removal of such an event, depending on how it was first assigned. [ticket:2949]
* - happy new yearMike Bayer2014-01-051-1/+1
|
* Generate API and resolve cross referencesVraj Mohan2013-11-171-4/+4
|
* Fix indentation issues in docstringspr/43Vraj Mohan2013-11-121-3/+3
|
* - spot checking of imports, obsolete functionsMike Bayer2013-08-171-1/+0
|
* - apply an import refactoring to the ORM as wellMike Bayer2013-08-141-32/+62
| | | | | | | | | - 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
* - update ORM event docs to include that you can listen on an unmapped base,Mike Bayer2013-07-311-29/+32
| | | | [ticket:2777]
* - Removal of event listeners is now implemented. The feature isMike Bayer2013-07-261-53/+52
| | | | | | | | | | | | | | | | 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.
* - The mechanism by which attribute events pass along anMike Bayer2013-07-261-6/+27
| | | | | | | | | | | | | | | | | | | :class:`.AttributeImpl` as an "initiator" token has been changed; the object is now an event-specific object called :class:`.attributes.Event`. Additionally, the attribute system no longer halts events based on a matching "initiator" token; this logic has been moved to be specific to ORM backref event handlers, which are the typical source of the re-propagation of an attribute event onto subsequent append/set/remove operations. End user code which emulates the behavior of backrefs must now ensure that recursive event propagation schemes are halted, if the scheme does not use the backref handlers. Using this new system, backref handlers can now peform a "two-hop" operation when an object is appended to a collection, associated with a new many-to-one, de-associated with the previous many-to-one, and then removed from a previous collection. Before this change, the last step of removal from the previous collection would not occur. [ticket:2789]
* Fixed bug in ORM-level event registration where the "raw" orMike Bayer2013-07-181-5/+8
| | | | | | "propagate" flags could potentially be mis-configured in some "unmapped base class" configurations. Also in 0.8.3. [ticket:2786]
* - create a new system where we can decorate an event methodMike Bayer2013-07-081-14/+50
| | | | | | | | | | | | | | | | 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]
* - A clear error message is emitted if an event handlerMike Bayer2013-02-251-4/+104
| | | | | | | | | | attempts to emit SQL on a Session within the after_commit() handler, where there is not a viable transaction in progress. [ticket:2662] - rework how SessionTransaction maintains state, using symbols instead. - add lots of notes and cross-linking for session events. - add a link to :func:`.select()` within :meth:`.FromClause.select`.
* happy new year (see #2645)Diana Clarke2013-01-011-1/+1
|
* just a pep8 pass of lib/sqlalchemy/orm/Diana Clarke2012-11-191-71/+88
|
* update the introMike Bayer2012-10-311-2/+2
|
* - do a straight __subclasses__ traversal here, so that we aren'tMike Bayer2012-10-281-9/+15
| | | | | | iterating through all mappers in memory when a new event is tacked onto an unmapped superclass, also removes the strong ref that was breaking some GC teardown tests
* - cover additional cases for [ticket:2585], where events are applied to base ↵Mike Bayer2012-10-281-1/+12
| | | | | | class after subclasses are already mapped
* - lets default propagate to True here since it was essentially alwaysMike Bayer2012-10-121-1/+7
| | | | propagated previously
* - [feature] Improvements to event listening forMike Bayer2012-10-121-9/+122
| | | | | | | | | | | | | | | | | | | mapped classes allows that unmapped classes can be specified for instance- and mapper-events. The established events will be automatically set up on subclasses of that class when the propagate=True flag is passed, and the events will be set up for that class itself if and when it is ultimately mapped. [ticket:2585] - [bug] The instrumentation events class_instrument(), class_uninstrument(), and attribute_instrument() will now fire off only for descendant classes of the class assigned to listen(). Previously, an event listener would be assigned to listen for all classes in all cases regardless of the "target" argument passed. [ticket:2590]
* mapper configured docMike Bayer2012-09-211-2/+10
|
* - [feature] New session events after_transaction_createMike Bayer2012-09-201-0/+20
| | | | | | | | and after_transaction_end allows tracking of new SessionTransaction objects. If the object is inspected, can be used to determine when a session first becomes active and when it deactivates.
* - rework scoped_session and sessionmaker, [ticket:2500]Mike Bayer2012-09-101-7/+15
| | | | - rewrite tons of session docs
* - modernize most of the postgis example. would like to do [ticket:1534] also.Mike Bayer2012-08-161-2/+4
| | | | | - we don't have coverage for type-wide instrumentation events, the listener was broke. could break again too.
* - update engine docstrings due to moveMike Bayer2012-08-131-1/+1
| | | | - struggle with Operators class autodoc
* - express most of the orm.util functions in terms of the inspection systemMike Bayer2012-07-161-173/+173
| | | | | | | | | | | | | | - modify inspection system: 1. raise a new exception for any case where the inspection context can't be returned. this supersedes the "not mapped" errors. 2. don't configure mappers on a mapper inspection. this allows the inspectors to be used during mapper config time. instead, the mapper configures on "with_polymorphic_selectable" now, which is needed for all queries - add a bunch of new "is_XYZ" attributes to inspectors - finish making the name change of "compile" -> "configure", for some reason this was only done partially
* - move all of orm to use absolute importsMike Bayer2012-06-231-1/+1
| | | | | | | | - break out key mechanics of loading objects into new "orm.loading" module, removing implementation details from both mapper.py and query.py. is analogous to persistence.py - some other cleanup and old cruft removal
* Add some `Sphinx` paragraph level versions informations markups,Mike Bayer2012-06-081-1/+1
| | | | such as ``.. versionadded::``, ``.. versionchanged::`` and ``.. deprecated::``.
* - add before_attach event, [ticket:2464]Mike Bayer2012-06-071-1/+27
|
* - [bug] Fixed bug whereby event.listen(SomeClass)Mike Bayer2012-01-071-1/+1
| | | | | | | forced an entirely unnecessary compile of the mapper, making events very hard to set up at module import time (nobody noticed this ??) [ticket:2367]