summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ext/declarative.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-06-08 15:55:08 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2012-06-08 15:55:08 -0400
commit27f7c595d216c8b1d87e5a3648ada09f684542d9 (patch)
treede07aa5ef8c3c012a322ab076897a62a07e11fe4 /lib/sqlalchemy/ext/declarative.py
parent97e97324d67056972b1f959ce41d0be441cec992 (diff)
downloadsqlalchemy-27f7c595d216c8b1d87e5a3648ada09f684542d9.tar.gz
Add some `Sphinx` paragraph level versions informations markups,
such as ``.. versionadded::``, ``.. versionchanged::`` and ``.. deprecated::``.
Diffstat (limited to 'lib/sqlalchemy/ext/declarative.py')
-rwxr-xr-xlib/sqlalchemy/ext/declarative.py27
1 files changed, 17 insertions, 10 deletions
diff --git a/lib/sqlalchemy/ext/declarative.py b/lib/sqlalchemy/ext/declarative.py
index 893fc988d..d7a9c8deb 100755
--- a/lib/sqlalchemy/ext/declarative.py
+++ b/lib/sqlalchemy/ext/declarative.py
@@ -509,10 +509,12 @@ before the class is built::
Using the Concrete Helpers
^^^^^^^^^^^^^^^^^^^^^^^^^^^
-New helper classes released in 0.7.3 provides a simpler pattern for concrete inheritance.
+Helper classes provides a simpler pattern for concrete inheritance.
With these objects, the ``__declare_last__`` helper is used to configure the "polymorphic"
loader for the mapper after all subclasses have been declared.
+.. versionadded:: 0.7.3
+
An abstract base can be declared using the :class:`.AbstractConcreteBase` class::
from sqlalchemy.ext.declarative import AbstractConcreteBase
@@ -674,8 +676,7 @@ keys, as a :class:`.ForeignKey` itself contains references to columns
which can't be properly recreated at this level. For columns that
have foreign keys, as well as for the variety of mapper-level constructs
that require destination-explicit context, the
-:func:`~.declared_attr` decorator (renamed from ``sqlalchemy.util.classproperty`` in 0.6.5)
-is provided so that
+:func:`~.declared_attr` decorator is provided so that
patterns common to many classes can be defined as callables::
from sqlalchemy.ext.declarative import declared_attr
@@ -694,6 +695,9 @@ point at which the ``User`` class is constructed, and the declarative
extension can use the resulting :class:`.Column` object as returned by
the method without the need to copy it.
+.. versionchanged:: > 0.6.5
+ Rename 0.6.5 ``sqlalchemy.util.classproperty`` into :func:`~.declared_attr`.
+
Columns generated by :func:`~.declared_attr` can also be
referenced by ``__mapper_args__`` to a limited degree, currently
by ``polymorphic_on`` and ``version_id_col``, by specifying the
@@ -931,7 +935,7 @@ Special Directives
``__declare_last__()``
~~~~~~~~~~~~~~~~~~~~~~
-The ``__declare_last__()`` hook, introduced in 0.7.3, allows definition of
+The ``__declare_last__()`` hook allows definition of
a class level function that is automatically called by the :meth:`.MapperEvents.after_configured`
event, which occurs after mappings are assumed to be completed and the 'configure' step
has finished::
@@ -942,12 +946,14 @@ has finished::
""
# do something with mappings
+.. versionadded:: 0.7.3
+
.. _declarative_abstract:
``__abstract__``
~~~~~~~~~~~~~~~~~~~
-``__abstract__`` is introduced in 0.7.3 and causes declarative to skip the production
+``__abstract__`` causes declarative to skip the production
of a table or mapper for the class entirely. A class can be added within a hierarchy
in the same way as mixin (see :ref:`declarative_mixins`), allowing subclasses to extend
just from the special class::
@@ -985,6 +991,8 @@ The tables themselves can then be created perhaps within distinct databases::
DefaultBase.metadata.create_all(some_engine)
OtherBase.metadata_create_all(some_other_engine)
+.. versionadded:: 0.7.3
+
Class Constructor
=================
@@ -1568,11 +1576,10 @@ class declared_attr(property):
"""Mark a class-level method as representing the definition of
a mapped property or special declarative member name.
- .. note::
-
- @declared_attr is available as
- ``sqlalchemy.util.classproperty`` for SQLAlchemy versions
- 0.6.2, 0.6.3, 0.6.4.
+ .. versionchanged:: 0.6.{2,3,4}
+ ``@declared_attr`` is available as
+ ``sqlalchemy.util.classproperty`` for SQLAlchemy versions
+ 0.6.2, 0.6.3, 0.6.4.
@declared_attr turns the attribute into a scalar-like
property that can be invoked from the uninstantiated class.