SQLAlchemy 0.3 Documentation - module sqlalchemy.orm.interfaces

# SQLAlchemy 0.3 Documentation

Multiple Pages | One Page
Version: 0.3.10 Last Updated: 07/20/07 17:20:04

### module sqlalchemy.orm.interfaces

### class LoaderStrategy(object)

Describe the loading behavior of a StrategizedProperty object.

The `LoaderStrategy` interacts with the querying process in three ways:

- it controls the configuration of the `InstrumentedAttribute` placed on a class to handle the behavior of the attribute. this may involve setting up class-level callable functions to fire off a select operation when the attribute is first accessed (i.e. a lazy load)
- it processes the `QueryContext` at statement construction time, where it can modify the SQL statement that is being produced. simple column attributes may add their represented column to the list of selected columns, eager loading properties may add `LEFT OUTER JOIN` clauses to the statement.
- it processes the SelectionContext at row-processing time. This may involve setting instance-level lazyloader functions on newly constructed instances, or may involve recursively appending child items to a list in response to additionally eager-loaded objects in the query.

def __init__(self, parent)
def init(self)
def init_class_attribute(self)
def process_row(self, selectcontext, instance, row, identitykey, isnew)
def setup_query(self, context, **kwargs)
back to section top

### class MapperOption(object)

Describe a modification to an OperationContext or Query.

def process_query(self, query)
def process_query_context(self, context)
def process_selection_context(self, context)
back to section top

### class MapperProperty(object)

Manage the relationship of a `Mapper` to a single class attribute, as well as that attribute as it appears on individual instances of the class, including attribute instrumentation, attribute access, loading behavior, and dependency calculations.

def cascade_callable(self, type, object, callable_, recursive=None, halt_on=None)
def cascade_iterator(self, type, object, recursive=None, halt_on=None)
def compare(self, value)

Return a compare operation for the columns represented by this `MapperProperty` to the given value, which may be a column value or an instance.

def do_init(self)

Template method for subclasses.

def execute(self, selectcontext, instance, row, identitykey, isnew)

Called when the mapper receives a row.

instance is the parent instance corresponding to the row.

def get_criterion(self, query, key, value)

Return a `WHERE` clause suitable for this `MapperProperty` corresponding to the given key/value pair, where the key is a column or object property name, and value is a value to be matched. This is only picked up by `PropertyLoaders`.

This is called by a `Query`'s `join_by` method to formulate a set of key/value pairs into a `WHERE` criterion that spans multiple tables if needed.

def init(self, key, parent)

Called after all mappers are compiled to assemble relationships between mappers, establish instrumented class attributes.

def is_primary(self)

Return True if this `MapperProperty`'s mapper is the primary mapper for its class.

This flag is used to indicate that the `MapperProperty` can define attribute instrumentation for the class at the class level (as opposed to the individual instance level).

def merge(self, session, source, dest)

Merge the attribute represented by this `MapperProperty` from source to destination object

def register_dependencies(self, *args, **kwargs)

Called by the `Mapper` in response to the UnitOfWork calling the `Mapper`'s register_dependencies operation. Should register with the UnitOfWork all inter-mapper dependencies as well as dependency processors (see UOW docs for more details).

def set_parent(self, parent)
def setup(self, querycontext, **kwargs)

Called when a statement is being constructed.

back to section top

### class OperationContext(object)

Serve as a context during a query construction or instance loading operation.

Accept `MapperOption` objects which may modify its state before proceeding.

def __init__(self, mapper, options)
def accept_option(self, opt)
back to section top

### class PropertyOption(MapperOption)

A MapperOption that is applied to a property off the mapper or one of its child mappers, identified by a dot-separated key.

def __init__(self, key)
def process_query_context(self, context)
def process_query_property(self, context, property)
def process_selection_context(self, context)
def process_selection_property(self, context, property)
back to section top

### class StrategizedOption(PropertyOption)

A MapperOption that affects which LoaderStrategy will be used for an operation by a StrategizedProperty.

def get_strategy_class(self)
def process_query_property(self, context, property)
def process_selection_property(self, context, property)
back to section top

### class StrategizedProperty(MapperProperty)

A MapperProperty which uses selectable strategies to affect loading behavior.

There is a single default strategy selected, and alternate strategies can be selected at selection time through the usage of `StrategizedOption` objects.

def do_init(self)
def execute(self, selectcontext, instance, row, identitykey, isnew)
def setup(self, querycontext, **kwargs)
back to section top

### class SynonymProperty(MapperProperty)

def __init__(self, name, proxy=False)
def do_init(self)
def execute(self, selectcontext, instance, row, identitykey, isnew)
def merge(self, session, source, dest, _recursive)
def setup(self, querycontext, **kwargs)
back to section top