summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ext/declarative.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-08-03 12:56:02 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2010-08-03 12:56:02 -0400
commit54feab41f9fc81966da1f6e7bc35344c8ba5f604 (patch)
treec4649019e2afd60233208d49779d84835706a11b /lib/sqlalchemy/ext/declarative.py
parentbc8787a351004e5077c7c18869fb20f000d3b4db (diff)
downloadsqlalchemy-54feab41f9fc81966da1f6e7bc35344c8ba5f604.tar.gz
- dont like this note
- rewrite this section, also don't talk about extensions anymore since they will be replaced
Diffstat (limited to 'lib/sqlalchemy/ext/declarative.py')
-rwxr-xr-xlib/sqlalchemy/ext/declarative.py30
1 files changed, 15 insertions, 15 deletions
diff --git a/lib/sqlalchemy/ext/declarative.py b/lib/sqlalchemy/ext/declarative.py
index 90ce5b779..2310f01ce 100755
--- a/lib/sqlalchemy/ext/declarative.py
+++ b/lib/sqlalchemy/ext/declarative.py
@@ -369,20 +369,25 @@ such as those which already take advantage of the data-driven nature of
Mapper Configuration
====================
-Configuration of mappers is done with the
-:func:`~sqlalchemy.orm.mapper` function and all the possible mapper
-configuration parameters can be found in the documentation for that
-function.
-
-:func:`~sqlalchemy.orm.mapper` is still used by declaratively mapped
-classes and keyword parameters to the function can be passed by
-placing them in the ``__mapper_args__`` class variable::
-
+Declarative makes use of the :func:`~.orm.mapper` function internally
+when it creates the mapping to the declared table. The options
+for :func:`~.orm.mapper` are passed directly through via the ``__mapper_args__``
+class attribute. As always, arguments which reference locally
+mapped columns can reference them directly from within the
+class declaration::
+
+ from datetime import datetime
+
class Widget(Base):
__tablename__ = 'widgets'
+
id = Column(Integer, primary_key=True)
+ timestamp = Column(DateTime, nullable=False)
- __mapper_args__ = {'extension': MyWidgetExtension()}
+ __mapper_args__ = {
+ 'version_id_col': timestamp,
+ 'version_id_generator': lambda v:datetime.now()
+ }
Inheritance Configuration
=========================
@@ -520,11 +525,6 @@ share some functionality, often a set of columns, across many
classes. The normal Python idiom would be to put this common code into
a base class and have all the other classes subclass this class.
-.. note:: Mixins are an entirely optional feature when using declarative,
- and are not required for any configuration. Users who don't need
- to define sets of attributes common among many classes can
- skip this section.
-
When using :mod:`~sqlalchemy.ext.declarative`, this need is met by
using a "mixin class". A mixin class is one that isn't mapped to a
table and doesn't subclass the declarative :class:`Base`. For example::