-0.2.9
+0.3.0
- General:
- logging is now implemented via standard python "logging" module.
"echo" keyword parameters are still functional but set/unset
can be controlled directly through the Python API by setting
INFO and DEBUG levels for loggers in the "sqlalchemy" namespace.
class-level logging is under "sqlalchemy.<module>.<classname>",
- instance-level logging under "sqlalchemy.<module>.<classname>.<hexid>".
+ instance-level logging under "sqlalchemy.<module>.<classname>.0x..<00-FF>".
Test suite includes "--log-info" and "--log-debug" arguments
which work independently of --verbose/--quiet. Logging added
to orm to allow tracking of mapper configurations, row iteration.
ColumnProperty and PropertyLoader define their loading behaivor via switchable
"strategies", and MapperOptions no longer use mapper/property copying
in order to function; they are instead propigated via QueryContext
- and SelectionContext objects at query/instnaces time.
- All of the copying of mappers and properties that was used to handle
+ and SelectionContext objects at query/instances time.
+ All of the internal copying of mappers and properties that was used to handle
inheritance as well as options() has been removed; the structure
- of mappers and properties is simpler than before and clearly laid out.
+ of mappers and properties is much simpler than before and is clearly laid out
+ in the new 'interfaces' module.
- related to the mapper/property overhaul, internal refactoring to
mapper instances() method to use a SelectionContext object to track
state during the operation.
def make_doc(obj, classes=None, functions=None):
objects.append(docstring.ObjectDoc(obj, classes=classes, functions=functions))
-make_doc(obj=sql, classes=[sql.Engine, sql.AbstractDialect, sql.ClauseParameters, sql.Compiled, sql.ClauseElement, sql.TableClause, sql.ColumnClause])
+make_doc(obj=sql, classes=[])
make_doc(obj=schema)
make_doc(obj=engine, classes=[engine.Connectable, engine.ComposedSQLEngine, engine.Connection, engine.Transaction, engine.Dialect, engine.ConnectionProvider, engine.ExecutionContext, engine.ResultProxy, engine.RowProxy])
-make_doc(obj=strategies)
-make_doc(obj=orm, classes=[orm.Mapper, orm.MapperExtension, orm.SelectionContext])
-make_doc(obj=orm.query, classes=[orm.query.Query])
+make_doc(obj=orm)
make_doc(obj=orm.session, classes=[orm.session.Session, orm.session.SessionTransaction])
make_doc(obj=pool, classes=[pool.DBProxy, pool.Pool, pool.QueuePool, pool.SingletonThreadPool])
make_doc(obj=sessioncontext)
**Author:** Daniel Miller
-This plugin is used to instantiate and manage Session objects. It provides several services:
+This plugin is used to instantiate and manage Session objects. As of SQLAlchemy 0.2 it is the preferred way to provide thread-local session functionality to an application. It provides several services:
* serves as a factory to create sessions of a particular configuration. This factory may either call `create_session()` with a particular set of arguments, or instantiate a different implementation of `Session` if one is available.
* for the `Session` objects it creates, provides the ability to maintain a single `Session` per distinct application thread. The `Session` returned by a `SessionContext` is called the *contextual session.* Providing at least a thread-local context to sessions is important because the `Session` object is not threadsafe, and is intended to be used with localized sets of data, as opposed to a single session being used application wide.
the callable will only be executed if the given 'passive' flag is False.
"""
attr = getattr(obj.__class__, key)
- print "ATTR IS A", attr, "OBJ IS A", obj
x = attr.get(obj, passive=passive)
if x is InstrumentedAttribute.PASSIVE_NORESULT:
return []
from sqlalchemy import sql, schema, engine, util, exceptions
from mapper import *
from mapper import mapper_registry
+import mapper as mapperlib
from query import Query
from util import polymorphic_union
import properties, strategies
return properties.BackRef(name, **kwargs)
def deferred(*columns, **kwargs):
- """returns a DeferredColumnProperty, which indicates this object attributes should only be loaded
+ """return a DeferredColumnProperty, which indicates this object attributes should only be loaded
from its corresponding table column when first accessed."""
return properties.ColumnProperty(deferred=True, *columns, **kwargs)
def mapper(class_, table=None, *args, **params):
- """returns a newMapper object."""
+ """return a new Mapper object."""
return Mapper(class_, table, *args, **params)
def synonym(name):
return SynonymProperty(name)
def clear_mappers():
- """removes all mappers that have been created thus far. when new mappers are
+ """remove all mappers that have been created thus far. when new mappers are
created, they will be assigned to their classes as their primary mapper."""
mapper_registry.clear()
def clear_mapper(m):
- """removes the given mapper from the storage of mappers. when a new mapper is
+ """remove the given mapper from the storage of mappers. when a new mapper is
created for the previous mapper's class, it will be used as that classes'
new primary mapper."""
del mapper_registry[m.hash_key]
def eagerload(name):
- """returns a MapperOption that will convert the property of the given name
+ """return a MapperOption that will convert the property of the given name
into an eager load."""
return strategies.EagerLazyOption(name, lazy=False)
def lazyload(name):
- """returns a MapperOption that will convert the property of the given name
+ """return a MapperOption that will convert the property of the given name
into a lazy load"""
return strategies.EagerLazyOption(name, lazy=True)
class LoaderStrategy(object):
"""describes 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.
self.identity_map = {}
super(SelectionContext, self).__init__(mapper, kwargs.pop('with_options', []), **kwargs)
-
-class ExtensionOption(MapperOption):
- """adds a new MapperExtension to a mapper's chain of extensions"""
- def __init__(self, ext):
- self.ext = ext
- def process(self, mapper):
- self.ext.next = mapper.extension
- mapper.extension = self.ext
-
class MapperExtension(object):
"""base implementation for an object that provides overriding behavior to various
Mapper functions. For each method in MapperExtension, a result of EXT_PASS indicates
def __repr__(self):
return "ClassKey(%s, %s)" % (repr(self.class_), repr(self.entity_name))
-def hash_key(obj):
- if obj is None:
- return 'None'
- elif isinstance(obj, list):
- return repr([hash_key(o) for o in obj])
- elif hasattr(obj, 'hash_key'):
- return obj.hash_key()
- else:
- return repr(obj)
-
def has_identity(object):
return hasattr(object, '_instance_key')