]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- dont like this note
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 3 Aug 2010 16:56:02 +0000 (12:56 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 3 Aug 2010 16:56:02 +0000 (12:56 -0400)
- rewrite this section, also don't talk about extensions anymore
since they will be replaced

lib/sqlalchemy/ext/declarative.py

index 90ce5b7798476d73feeed8b4ca9b39a85103cfd4..2310f01ce3a4f12f4feaa55742f0e6b082b38771 100755 (executable)
@@ -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::