summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2008-08-28 18:21:42 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2008-08-28 18:21:42 +0000
commita18035cfb16d8b55e460a9f3752c3b9f697e7729 (patch)
treecb975fd218e3a81d88b2f97310e5cadd9433b4ed /lib/sqlalchemy/orm
parentaf342bba5600fc312f8efc1d3942301c57ca845f (diff)
downloadsqlalchemy-a18035cfb16d8b55e460a9f3752c3b9f697e7729.tar.gz
- starargs_as_list was not actually issuing SAPendingDeprecationWarning, fixed
- implemented code cleanup from [ticket:1152] but not including using the decorators module
Diffstat (limited to 'lib/sqlalchemy/orm')
-rw-r--r--lib/sqlalchemy/orm/attributes.py23
-rw-r--r--lib/sqlalchemy/orm/dependency.py12
-rw-r--r--lib/sqlalchemy/orm/mapper.py10
-rw-r--r--lib/sqlalchemy/orm/properties.py2
-rw-r--r--lib/sqlalchemy/orm/query.py4
5 files changed, 32 insertions, 19 deletions
diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py
index 88e124e4b..0b36d5f0c 100644
--- a/lib/sqlalchemy/orm/attributes.py
+++ b/lib/sqlalchemy/orm/attributes.py
@@ -197,7 +197,9 @@ def proxied_attribute_factory(descriptor):
class AttributeImpl(object):
"""internal implementation for instrumented attributes."""
- def __init__(self, class_, key, callable_, class_manager, trackparent=False, extension=None, compare_function=None, active_history=False, **kwargs):
+ def __init__(self, class_, key,
+ callable_, class_manager, trackparent=False, extension=None,
+ compare_function=None, active_history=False, **kwargs):
"""Construct an AttributeImpl.
\class_
@@ -426,8 +428,11 @@ class MutableScalarAttributeImpl(ScalarAttributeImpl):
uses_objects = False
- def __init__(self, class_, key, callable_, class_manager, copy_function=None, compare_function=None, **kwargs):
- super(ScalarAttributeImpl, self).__init__(class_, key, callable_, class_manager, compare_function=compare_function, **kwargs)
+ def __init__(self, class_, key, callable_,
+ class_manager, copy_function=None,
+ compare_function=None, **kwargs):
+ super(ScalarAttributeImpl, self).__init__(class_, key, callable_,
+ class_manager, compare_function=compare_function, **kwargs)
class_manager.mutable_attributes.add(key)
if copy_function is None:
raise sa_exc.ArgumentError("MutableScalarAttributeImpl requires a copy function")
@@ -467,7 +472,9 @@ class ScalarObjectAttributeImpl(ScalarAttributeImpl):
accepts_scalar_loader = False
uses_objects = True
- def __init__(self, class_, key, callable_, class_manager, trackparent=False, extension=None, copy_function=None, compare_function=None, **kwargs):
+ def __init__(self, class_, key, callable_, class_manager,
+ trackparent=False, extension=None, copy_function=None,
+ compare_function=None, **kwargs):
super(ScalarObjectAttributeImpl, self).__init__(class_, key,
callable_, class_manager, trackparent=trackparent, extension=extension,
compare_function=compare_function, **kwargs)
@@ -542,7 +549,9 @@ class CollectionAttributeImpl(AttributeImpl):
accepts_scalar_loader = False
uses_objects = True
- def __init__(self, class_, key, callable_, class_manager, typecallable=None, trackparent=False, extension=None, copy_function=None, compare_function=None, **kwargs):
+ def __init__(self, class_, key, callable_, class_manager,
+ typecallable=None, trackparent=False, extension=None,
+ copy_function=None, compare_function=None, **kwargs):
super(CollectionAttributeImpl, self).__init__(class_,
key, callable_, class_manager, trackparent=trackparent,
extension=extension, compare_function=compare_function, **kwargs)
@@ -1427,7 +1436,9 @@ def unregister_class(class_):
manager.instantiable = False
manager.unregister()
-def register_attribute(class_, key, uselist, useobject, callable_=None, proxy_property=None, mutable_scalars=False, impl_class=None, **kwargs):
+def register_attribute(class_, key, uselist, useobject,
+ callable_=None, proxy_property=None,
+ mutable_scalars=False, impl_class=None, **kwargs):
manager = manager_of_class(class_)
if manager.is_instrumented(key):
return
diff --git a/lib/sqlalchemy/orm/dependency.py b/lib/sqlalchemy/orm/dependency.py
index 5fcaa4ab0..f54c8f85f 100644
--- a/lib/sqlalchemy/orm/dependency.py
+++ b/lib/sqlalchemy/orm/dependency.py
@@ -488,14 +488,14 @@ class ManyToManyDP(DependencyProcessor):
return sync.source_changes(uowcommit, state, self.parent, self.prop.synchronize_pairs)
class MapperStub(object):
- """Pose as a Mapper representing the association table in a
- many-to-many join, when performing a ``flush()``.
+ """Represent a many-to-many dependency within a flush
+ context.
+
+ The UOWTransaction corresponds dependencies to mappers.
+ MapperStub takes the place of the "association table"
+ so that a depedendency can be corresponded to it.
- The ``Task`` objects in the objectstore module treat it just like
- any other ``Mapper``, but in fact it only serves as a dependency
- placeholder for the many-to-many update task.
"""
-
__metaclass__ = util.ArgSingleton
def __init__(self, parent, mapper, key):
diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py
index ac14b5daf..99593e889 100644
--- a/lib/sqlalchemy/orm/mapper.py
+++ b/lib/sqlalchemy/orm/mapper.py
@@ -280,14 +280,14 @@ class Mapper(object):
return from_obj
@property
- @util.cache_decorator
+ @util.memoize
def _with_polymorphic_mappers(self):
if not self.with_polymorphic:
return [self]
return self.__mappers_from_spec(*self.with_polymorphic)
@property
- @util.cache_decorator
+ @util.memoize
def _with_polymorphic_selectable(self):
if not self.with_polymorphic:
return self.mapped_table
@@ -463,7 +463,7 @@ class Mapper(object):
self.version_id_col = self.inherits.version_id_col
for mapper in self.iterate_to_root():
- util.reset_cached(mapper, '_equivalent_columns')
+ util.reset_memoized(mapper, '_equivalent_columns')
if self.order_by is False and not self.concrete and self.inherits.order_by is not False:
self.order_by = self.inherits.order_by
@@ -557,7 +557,7 @@ class Mapper(object):
self.__log("Identified primary key columns: " + str(primary_key))
@property
- @util.cache_decorator
+ @util.memoize
def _get_clause(self):
"""create a "get clause" based on the primary key. this is used
by query.get() and many-to-one lazyloads to load this item
@@ -568,7 +568,7 @@ class Mapper(object):
return sql.and_(*[k==v for (k, v) in params]), dict(params)
@property
- @util.cache_decorator
+ @util.memoize
def _equivalent_columns(self):
"""Create a map of all *equivalent* columns, based on
the determination of column pairs that are equated to
diff --git a/lib/sqlalchemy/orm/properties.py b/lib/sqlalchemy/orm/properties.py
index 075dde081..bbec29967 100644
--- a/lib/sqlalchemy/orm/properties.py
+++ b/lib/sqlalchemy/orm/properties.py
@@ -82,9 +82,9 @@ class ColumnProperty(StrategizedProperty):
return value
class ColumnComparator(PropComparator):
+ @util.memoize
def __clause_element__(self):
return self.prop.columns[0]._annotate({"parententity": self.mapper})
- __clause_element__ = util.cache_decorator(__clause_element__)
def operate(self, op, *other, **kwargs):
return op(self.__clause_element__(), *other, **kwargs)
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py
index c1030aaf7..6c20a1fe3 100644
--- a/lib/sqlalchemy/orm/query.py
+++ b/lib/sqlalchemy/orm/query.py
@@ -43,6 +43,8 @@ aliased = AliasedClass
def _generative(*assertions):
"""Mark a method as generative."""
+
+ @util.decorator
def generate(fn, *args, **kw):
self = args[0]._clone()
fn_name = fn.func_name
@@ -50,7 +52,7 @@ def _generative(*assertions):
assertion(self, fn_name)
fn(self, *args[1:], **kw)
return self
- return util.decorator(generate)
+ return generate
class Query(object):
"""Encapsulates the object-fetching operations provided by Mappers."""