summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ext/declarative/api.py
diff options
context:
space:
mode:
authorDiana Clarke <diana.joan.clarke@gmail.com>2012-11-19 13:31:21 -0500
committerDiana Clarke <diana.joan.clarke@gmail.com>2012-11-19 13:31:21 -0500
commitef326d9fe39ab493dd4aeaf2cecf9052a04d49b7 (patch)
tree0684ba72e53a9321a36f07a3a8a5dcec833b55e5 /lib/sqlalchemy/ext/declarative/api.py
parent34b8b22659999eae459ca33baa3ca479f8eb5bf1 (diff)
downloadsqlalchemy-ef326d9fe39ab493dd4aeaf2cecf9052a04d49b7.tar.gz
just a pep8 pass of lib/sqlalchemy/ext/declarative
Diffstat (limited to 'lib/sqlalchemy/ext/declarative/api.py')
-rw-r--r--lib/sqlalchemy/ext/declarative/api.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/sqlalchemy/ext/declarative/api.py b/lib/sqlalchemy/ext/declarative/api.py
index 0db3f4e6b..b4b6f733b 100644
--- a/lib/sqlalchemy/ext/declarative/api.py
+++ b/lib/sqlalchemy/ext/declarative/api.py
@@ -33,6 +33,7 @@ def instrument_declarative(cls, registry, metadata):
cls.metadata = metadata
_as_declarative(cls, cls.__name__, cls.__dict__)
+
def has_inherited_table(cls):
"""Given a class, return True if any of the classes it inherits from has a
mapped table, otherwise return False.
@@ -42,6 +43,7 @@ def has_inherited_table(cls):
return True
return False
+
class DeclarativeMeta(type):
def __init__(cls, classname, bases, dict_):
if '_decl_class_registry' not in cls.__dict__:
@@ -51,6 +53,7 @@ class DeclarativeMeta(type):
def __setattr__(cls, key, value):
_add_attribute(cls, key, value)
+
def synonym_for(name, map_column=False):
"""Decorator, make a Python @property a query synonym for a column.
@@ -73,6 +76,7 @@ def synonym_for(name, map_column=False):
return _orm_synonym(name, map_column=map_column, descriptor=fn)
return decorate
+
def comparable_using(comparator_factory):
"""Decorator, allow a Python @property to be used in query criteria.
@@ -95,6 +99,7 @@ def comparable_using(comparator_factory):
return comparable_property(comparator_factory, fn)
return decorate
+
class declared_attr(interfaces._MappedAttribute, property):
"""Mark a class-level method as representing the definition of
a mapped property or special declarative member name.
@@ -154,6 +159,7 @@ class declared_attr(interfaces._MappedAttribute, property):
def __get__(desc, self, cls):
return desc.fget(cls)
+
def declarative_base(bind=None, metadata=None, mapper=None, cls=object,
name='Base', constructor=_declarative_constructor,
class_registry=None,
@@ -231,6 +237,7 @@ def declarative_base(bind=None, metadata=None, mapper=None, cls=object,
return metaclass(name, bases, class_dict)
+
class ConcreteBase(object):
"""A helper class for 'concrete' declarative mappings.
@@ -285,6 +292,7 @@ class ConcreteBase(object):
m._set_with_polymorphic(("*", pjoin))
m._set_polymorphic_on(pjoin.c.type)
+
class AbstractConcreteBase(ConcreteBase):
"""A helper class for 'concrete' declarative mappings.
@@ -362,7 +370,8 @@ class DeferredReflection(object):
method is called which first reflects all :class:`.Table`
objects created so far. Classes can define it as such::
- from sqlalchemy.ext.declarative import declarative_base, DeferredReflection
+ from sqlalchemy.ext.declarative import declarative_base
+ from sqlalchemy.ext.declarative import DeferredReflection
Base = declarative_base()
class MyClass(DeferredReflection, Base):
@@ -370,7 +379,8 @@ class DeferredReflection(object):
Above, ``MyClass`` is not yet mapped. After a series of
classes have been defined in the above fashion, all tables
- can be reflected and mappings created using :meth:`.DeferredReflection.prepare`::
+ can be reflected and mappings created using
+ :meth:`.DeferredReflection.prepare`::
engine = create_engine("someengine://...")
DeferredReflection.prepare(engine)