Given a class and optional entity_name, return the primary Mapper associated with the key.
If no mapper can be located, raises InvalidRequestError.
Given an object, return the primary Mapper associated with the object instance.
Base implementation for an object that provides overriding behavior to various Mapper functions. For each method in MapperExtension, a result of EXT_PASS indicates the functionality is not overridden.
Receive an object instance after that instance is DELETEed.
Receive an object instance after that instance is INSERTed.
Receive an object instance after that instance is UPDATEed.
Receive an object instance before that instance is appended to a result list.
If this method returns EXT_PASS, result appending will proceed normally. if this method returns any other value or None, result appending will not proceed for this instance, giving this extension an opportunity to do the appending itself, if desired.
Receive an object instance before that instance is DELETEed.
Receive an object instance before that instance is INSERTed into its table.
This is a good place to set up primary key values and such that aren't handled otherwise.
Receive an object instance before that instance is UPDATEed.
Receive a row when a new object instance is about to be created from that row.
The method can choose to create the instance itself, or it can return None to indicate normal object creation should take place.
Override the get method of the Query object.
The return value of this method is used as the result of query.get() if the value is anything other than EXT_PASS.
Override the get_by method of the Query object.
The return value of this method is used as the result of query.get_by() if the value is anything other than EXT_PASS.
Retrieve a contextual Session instance with which to register a new object.
Note: this is not called if a session is provided with the __init__ params (i.e. _sa_session).
Override the load method of the Query object.
The return value of this method is used as the result of query.load() if the value is anything other than EXT_PASS.
Receive a newly-created instance before that instance has its attributes populated.
The normal population of attributes is according to each attribute's corresponding MapperProperty (which includes column-based attributes as well as relationships to other classes). If this method returns EXT_PASS, instance population will proceed normally. If any other value or None is returned, instance population will not proceed, giving this extension an opportunity to populate the instance itself, if desired.
Override the select method of the Query object.
The return value of this method is used as the result of query.select() if the value is anything other than EXT_PASS.
Override the select_by method of the Query object.
The return value of this method is used as the result of query.select_by() if the value is anything other than EXT_PASS.
Perform pre-processing on the given result row and return a new row instance.
This is called as the very first step in the _instance() method.
Define the correlation of class attributes to database table columns.
Instances of this class should be constructed via the sqlalchemy.orm.mapper() function.
Construct a new mapper.
All arguments may be sent to the sqlalchemy.orm.mapper() function where they are passed through to here.
Add the given dictionary of properties to this mapper, using add_property.
Add an indiviual MapperProperty to this mapper.
If the mapper has not been compiled yet, just adds the property to the initial properties dictionary sent to the constructor. If this Mapper has already been compiled, then the given MapperProperty is compiled immediately.
Execute a callable for each element in an object graph, for all relations that meet the given cascade rule.
Iterate each element in an object graph, for all relations taht meet the given cascade rule.
Return true if the given mapper shares a common inherited parent as this mapper.
Compile this mapper into its final internal format.
This is the external version of the method which is not reentrant.
Issue DELETE statements for a list of objects.
This is called within the context of a UOWTransaction during a flush operation.
Return an instance attribute using a Column as the key.
Return the mapper used for issuing selects.
This mapper is the same mapper as self unless the select_table argument was specified for this mapper.
Return the contextual session provided by the mapper extension chain, if any.
Raise InvalidRequestError if a session cannot be retrieved from the extension chain.
Return the identity key for the given instance, based on its primary key attributes.
This value is typically also found on the instance itself under the attribute name _instance_key.
Return an identity-map key for use in storing/retrieving an item from an identity map.
Return an identity-map key for use in storing/retrieving an item from the identity map.
Return a list of mapped instances corresponding to the rows in a given ResultProxy.
Return True if this mapper handles the given instance.
This is dependent not only on class assignment but the optional entity_name parameter as well.
Iterate through the collection including this mapper and all descendant mappers.
This includes not just the immediately inheriting mappers but all their inheriting mappers as well.
To iterate through an entire hierarchy, use mapper.base_mapper().polymorphic_iterator().
populate an instance from a result row.
This method iterates through the list of MapperProperty objects attached to this Mapper and calls each properties execute() method.
Return the list of primary key values for the given instance.
Return the primary mapper corresponding to this mapper's class key (class + entity_name).
compiles this mapper if needed, and returns the dictionary of MapperProperty objects associated with this mapper.
Register DependencyProcessor instances with a unitofwork.UOWTransaction.
This call register_dependencies on all attached MapperProperty instances.
Issue INSERT and/or UPDATE statements for a list of objects.
This is called within the context of a UOWTransaction during a flush operation.
save_obj issues SQL statements not just for instances mapped directly by this mapper, but for instances mapped by all inheriting mappers as well. This is to maintain proper insert ordering among a polymorphic chain of instances. Therefore save_obj is typically called only on a base mapper, or a mapper which does not inherit from any other mapper.
Set the value of an instance attribute using a Column as the key.
Translate the column keys of a row into a new or proxied row that can be understood by another mapper.
This can be used in conjunction with populate_instance to populate an instance using an alternate mapper.