summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/util.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2011-01-02 14:23:42 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2011-01-02 14:23:42 -0500
commit350aed3fdb9f1e73e69655e53f44ca6a91c196da (patch)
tree3d2a128667b5f6ca6d0b4e1f4865fc98aac6b60b /lib/sqlalchemy/orm/util.py
parent71f92436bdc86f30e2c21d8f5244733601e8c39e (diff)
downloadsqlalchemy-350aed3fdb9f1e73e69655e53f44ca6a91c196da.tar.gz
- whitespace removal bonanza
Diffstat (limited to 'lib/sqlalchemy/orm/util.py')
-rw-r--r--lib/sqlalchemy/orm/util.py38
1 files changed, 19 insertions, 19 deletions
diff --git a/lib/sqlalchemy/orm/util.py b/lib/sqlalchemy/orm/util.py
index a69670c29..7866aab2b 100644
--- a/lib/sqlalchemy/orm/util.py
+++ b/lib/sqlalchemy/orm/util.py
@@ -28,7 +28,7 @@ class CascadeOptions(dict):
values = set()
else:
values = set(c.strip() for c in arg.split(','))
-
+
for name in ['save-update', 'delete', 'refresh-expire',
'merge', 'expunge']:
boolean = name in values or 'all' in values
@@ -38,7 +38,7 @@ class CascadeOptions(dict):
self.delete_orphan = "delete-orphan" in values
if self.delete_orphan:
self['delete-orphan'] = True
-
+
if self.delete_orphan and not self.delete:
util.warn("The 'delete-orphan' cascade option requires "
"'delete'. This will raise an error in 0.6.")
@@ -61,10 +61,10 @@ def _validator_events(desc, key, validator):
def set_(state, value, oldvalue, initiator):
return validator(state.obj(), key, value)
-
+
event.listen(desc, 'append', append, raw=True, retval=True)
event.listen(desc, 'set', set_, raw=True, retval=True)
-
+
def polymorphic_union(table_map, typecolname, aliasname='p_union'):
"""Create a ``UNION`` statement used by a polymorphic mapper.
@@ -197,8 +197,8 @@ class AliasedClass(object):
The ORM equivalent of a :func:`sqlalchemy.sql.expression.alias`
construct, this object mimics the mapped class using a
__getattr__ scheme and maintains a reference to a
- real :class:`~sqlalchemy.sql.expression.Alias` object.
-
+ real :class:`~sqlalchemy.sql.expression.Alias` object.
+
Usage is via the :class:`~sqlalchemy.orm.aliased()` synonym::
# find all pairs of users with the same name
@@ -264,7 +264,7 @@ class AliasedClass(object):
break
else:
raise AttributeError(key)
-
+
if isinstance(attr, attributes.QueryableAttribute):
return self.__adapt_prop(attr, key)
elif hasattr(attr, 'func_code'):
@@ -391,19 +391,19 @@ def with_parent(instance, prop):
"""Create filtering criterion that relates this query's primary entity
to the given related instance, using established :func:`.relationship()`
configuration.
-
+
The SQL rendered is the same as that rendered when a lazy loader
would fire off from the given parent on that attribute, meaning
that the appropriate state is taken from the parent object in
Python without the need to render joins to the parent table
in the rendered statement.
-
+
As of 0.6.4, this method accepts parent instances in all
persistence states, including transient, persistent, and detached.
Only the requisite primary key/foreign key attributes need to
be populated. Previous versions didn't work with transient
instances.
-
+
:param instance:
An instance which has some :func:`.relationship`.
@@ -411,7 +411,7 @@ def with_parent(instance, prop):
String property name, or class-bound attribute, which indicates
what relationship from the instance should be used to reconcile the
parent/child relationship.
-
+
"""
if isinstance(prop, basestring):
mapper = object_mapper(instance)
@@ -440,24 +440,24 @@ def _entity_info(entity, compile=True):
if isinstance(entity, mapperlib.Mapper):
mapper = entity
-
+
elif isinstance(entity, type):
class_manager = attributes.manager_of_class(entity)
-
+
if class_manager is None:
return None, entity, False
-
+
mapper = class_manager.mapper
else:
return None, entity, False
-
+
if compile and mapperlib.module._new_mappers:
mapperlib.configure_mappers()
return mapper, mapper._with_polymorphic_selectable, False
def _entity_descriptor(entity, key):
"""Return a class attribute given an entity and string name.
-
+
May return :class:`.InstrumentedAttribute` or user-defined
attribute.
@@ -516,7 +516,7 @@ def class_mapper(class_, compile=True):
Raises UnmappedClassError if no mapping is configured.
"""
-
+
try:
class_manager = attributes.manager_of_class(class_)
mapper = class_manager.mapper
@@ -542,7 +542,7 @@ def _class_to_mapper(class_or_mapper, compile=True):
mapper = class_or_mapper
else:
raise exc.UnmappedClassError(class_or_mapper)
-
+
if compile and mapperlib.module._new_mappers:
mapperlib.configure_mappers()
return mapper
@@ -581,7 +581,7 @@ def state_class_str(state):
return "None"
else:
return '<%s>' % (state.class_.__name__, )
-
+
def attribute_str(instance, attribute):
return instance_str(instance) + "." + attribute