~ubuntu-branches/debian/jessie/sqlalchemy/jessie

« back to all changes in this revision

Viewing changes to doc/orm/interfaces.html

  • Committer: Bazaar Package Importer
  • Author(s): Piotr Ożarowski
  • Date: 2011-08-01 23:18:16 UTC
  • mfrom: (1.4.15 upstream) (16.1.14 experimental)
  • Revision ID: james.westby@ubuntu.com-20110801231816-6lx797pi3q1fpqst
Tags: 0.7.2-1
* New upstream release
* Bump minimum required python-mako version to 0.4.1 (closes: 635898)

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
7
7
        
8
8
        <title>
9
 
                ORM Event Interfaces
10
 
             &mdash; SQLAlchemy 0.6.8 Documentation</title>
 
9
                Deprecated ORM Event Interfaces
 
10
             &mdash; SQLAlchemy 0.7 Documentation</title>
11
11
        
12
12
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
13
13
    <link rel="stylesheet" href="../_static/docs.css" type="text/css" />
15
15
    <script type="text/javascript">
16
16
      var DOCUMENTATION_OPTIONS = {
17
17
          URL_ROOT:    '../',
18
 
          VERSION:     '0.6.8',
 
18
          VERSION:     '0.7.2',
19
19
          COLLAPSE_MODINDEX: false,
20
20
          FILE_SUFFIX: '.html'
21
21
      };
27
27
    <link rel="index" title="Index" href="../genindex.html" />
28
28
    <link rel="search" title="Search" href="../search.html" />
29
29
        <link rel="copyright" title="Copyright" href="../copyright.html" />
30
 
    <link rel="top" title="SQLAlchemy 0.6.8 Documentation" href="../index.html" />
 
30
    <link rel="top" title="SQLAlchemy 0.7 Documentation" href="../index.html" />
31
31
        <link rel="up" title="SQLAlchemy ORM" href="index.html" />
32
 
        <link rel="next" title="ORM Extensions" href="extensions/index.html" />
33
 
        <link rel="prev" title="Relationship Loading Techniques" href="loading.html" />
 
32
        <link rel="next" title="ORM Exceptions" href="exceptions.html" />
 
33
        <link rel="prev" title="Examples" href="examples.html" />
34
34
 
35
35
    </head>
36
36
    <body>
38
38
 
39
39
 
40
40
 
41
 
<h1>SQLAlchemy 0.6.8 Documentation</h1>
 
41
<h1>SQLAlchemy 0.7 Documentation</h1>
42
42
 
43
43
<div id="search">
44
44
Search:
50
50
</div>
51
51
 
52
52
<div class="versionheader">
53
 
    Version: <span class="versionnum">0.6.8</span> Last Updated: 06/05/2011 13:10:26
 
53
    Release: <span class="versionnum">0.7.2</span> | Release Date: July 31, 2011
54
54
</div>
55
55
<div class="clearboth"></div>
56
56
 
58
58
    <div id="pagecontrol">
59
59
        <ul>
60
60
            <li>Prev:
61
 
            <a href="loading.html" title="previous chapter">Relationship Loading Techniques</a>
 
61
            <a href="examples.html" title="previous chapter">Examples</a>
62
62
            </li>
63
63
            <li>Next:
64
 
            <a href="extensions/index.html" title="next chapter">ORM Extensions</a>
 
64
            <a href="exceptions.html" title="next chapter">ORM Exceptions</a>
65
65
            </li>
66
66
 
67
67
        <li>
72
72
        </ul>
73
73
    </div>
74
74
    <div id="navbanner">
75
 
        <a class="totoc" href="../index.html">SQLAlchemy 0.6.8 Documentation</a>
 
75
        <a class="totoc" href="../index.html">SQLAlchemy 0.7 Documentation</a>
76
76
                » <a href="index.html" title="SQLAlchemy ORM">SQLAlchemy ORM</a>
77
77
        » 
78
 
                ORM Event Interfaces
 
78
                Deprecated ORM Event Interfaces
79
79
             
80
80
 
81
81
        <h2>
82
82
            
83
 
                ORM Event Interfaces
 
83
                Deprecated ORM Event Interfaces
84
84
            
85
85
        </h2>
86
86
        <ul>
87
 
<li><a class="reference internal" href="#">ORM Event Interfaces</a><ul>
 
87
<li><a class="reference internal" href="#">Deprecated ORM Event Interfaces</a><ul>
88
88
<li><a class="reference internal" href="#mapper-events">Mapper Events</a></li>
89
89
<li><a class="reference internal" href="#session-events">Session Events</a></li>
90
90
<li><a class="reference internal" href="#attribute-events">Attribute Events</a></li>
91
 
<li><a class="reference internal" href="#instrumentation-events-and-re-implementation">Instrumentation Events and Re-implementation</a></li>
92
91
</ul>
93
92
</li>
94
93
</ul>
101
100
    <div class="body">
102
101
        
103
102
<div class="section" id="module-sqlalchemy.orm.interfaces">
104
 
<span id="orm-event-interfaces"></span><span id="events-orm-toplevel"></span><span id="interfaces-orm-toplevel"></span><h1>ORM Event Interfaces<a class="headerlink" href="#module-sqlalchemy.orm.interfaces" title="Permalink to this headline">¶</a></h1>
105
 
<p>This section describes the various categories of events which can be intercepted
106
 
within the SQLAlchemy ORM.</p>
107
 
<p>For non-ORM event documentation, see <a class="reference internal" href="../core/interfaces.html"><em>Core Event Interfaces</em></a>.</p>
108
 
<p>A new version of this API with a significantly more flexible and consistent
109
 
interface will be available in version 0.7.</p>
 
103
<span id="deprecated-orm-event-interfaces"></span><span id="dep-interfaces-orm-toplevel"></span><h1>Deprecated ORM Event Interfaces<a class="headerlink" href="#module-sqlalchemy.orm.interfaces" title="Permalink to this headline">¶</a></h1>
 
104
<p>This section describes the class-based ORM event interface which first
 
105
existed in SQLAlchemy 0.1, which progressed with more kinds of events up
 
106
until SQLAlchemy 0.5.  The non-ORM analogue is described at <a class="reference internal" href="../core/interfaces.html"><em>Deprecated Event Interfaces</em></a>.</p>
 
107
<p>As of SQLAlchemy 0.7, the new event system described in
 
108
<a class="reference internal" href="../core/event.html"><em>Events</em></a> replaces the extension/proxy/listener system, providing
 
109
a consistent interface to all events without the need for subclassing.</p>
110
110
<div class="section" id="mapper-events">
111
111
<h2>Mapper Events<a class="headerlink" href="#mapper-events" title="Permalink to this headline">¶</a></h2>
112
 
<p>To use <a class="reference internal" href="#sqlalchemy.orm.interfaces.MapperExtension" title="sqlalchemy.orm.interfaces.MapperExtension"><tt class="xref py py-class docutils literal"><span class="pre">MapperExtension</span></tt></a>, make your own subclass of it and just send it off to a mapper:</p>
 
112
<dl class="class">
 
113
<dt id="sqlalchemy.orm.interfaces.MapperExtension">
 
114
<em class="property">class </em><tt class="descclassname">sqlalchemy.orm.interfaces.</tt><tt class="descname">MapperExtension</tt><a class="headerlink" href="#sqlalchemy.orm.interfaces.MapperExtension" title="Permalink to this definition">¶</a></dt>
 
115
<dd><p>Base implementation for <a class="reference internal" href="mapper_config.html#sqlalchemy.orm.mapper.Mapper" title="sqlalchemy.orm.mapper.Mapper"><tt class="xref py py-class docutils literal"><span class="pre">Mapper</span></tt></a> event hooks.</p>
 
116
<div class="admonition note">
 
117
<p class="first admonition-title">Note</p>
 
118
<p class="last"><a class="reference internal" href="#sqlalchemy.orm.interfaces.MapperExtension" title="sqlalchemy.orm.interfaces.MapperExtension"><tt class="xref py py-class docutils literal"><span class="pre">MapperExtension</span></tt></a> is deprecated.   Please
 
119
refer to <a class="reference internal" href="../core/event.html#sqlalchemy.event.listen" title="sqlalchemy.event.listen"><tt class="xref py py-func docutils literal"><span class="pre">event.listen()</span></tt></a> as well as 
 
120
<a class="reference internal" href="events.html#sqlalchemy.orm.events.MapperEvents" title="sqlalchemy.orm.events.MapperEvents"><tt class="xref py py-class docutils literal"><span class="pre">MapperEvents</span></tt></a>.</p>
 
121
</div>
 
122
<p>New extension classes subclass <a class="reference internal" href="#sqlalchemy.orm.interfaces.MapperExtension" title="sqlalchemy.orm.interfaces.MapperExtension"><tt class="xref py py-class docutils literal"><span class="pre">MapperExtension</span></tt></a> and are specified
 
123
using the <tt class="docutils literal"><span class="pre">extension</span></tt> mapper() argument, which is a single
 
124
<a class="reference internal" href="#sqlalchemy.orm.interfaces.MapperExtension" title="sqlalchemy.orm.interfaces.MapperExtension"><tt class="xref py py-class docutils literal"><span class="pre">MapperExtension</span></tt></a> or a list of such:</p>
113
125
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">sqlalchemy.orm.interfaces</span> <span class="kn">import</span> <span class="n">MapperExtension</span>
114
126
 
115
127
<span class="k">class</span> <span class="nc">MyExtension</span><span class="p">(</span><span class="n">MapperExtension</span><span class="p">):</span>
118
130
 
119
131
<span class="n">m</span> <span class="o">=</span> <span class="n">mapper</span><span class="p">(</span><span class="n">User</span><span class="p">,</span> <span class="n">users_table</span><span class="p">,</span> <span class="n">extension</span><span class="o">=</span><span class="n">MyExtension</span><span class="p">())</span></pre></div>
120
132
</div>
121
 
<p>Multiple extensions will be chained together and processed in order; they are specified as a list:</p>
 
133
<p>A single mapper can maintain a chain of <tt class="docutils literal"><span class="pre">MapperExtension</span></tt>
 
134
objects. When a particular mapping event occurs, the
 
135
corresponding method on each <tt class="docutils literal"><span class="pre">MapperExtension</span></tt> is invoked
 
136
serially, and each method has the ability to halt the chain
 
137
from proceeding further:</p>
122
138
<div class="highlight-python"><div class="highlight"><pre><span class="n">m</span> <span class="o">=</span> <span class="n">mapper</span><span class="p">(</span><span class="n">User</span><span class="p">,</span> <span class="n">users_table</span><span class="p">,</span> <span class="n">extension</span><span class="o">=</span><span class="p">[</span><span class="n">ext1</span><span class="p">,</span> <span class="n">ext2</span><span class="p">,</span> <span class="n">ext3</span><span class="p">])</span></pre></div>
123
139
</div>
124
 
<dl class="class">
125
 
<dt id="sqlalchemy.orm.interfaces.MapperExtension">
126
 
<em class="property">class </em><tt class="descclassname">sqlalchemy.orm.interfaces.</tt><tt class="descname">MapperExtension</tt><a class="headerlink" href="#sqlalchemy.orm.interfaces.MapperExtension" title="Permalink to this definition">¶</a></dt>
127
 
<dd><p>Base implementation for customizing <tt class="docutils literal"><span class="pre">Mapper</span></tt> behavior.</p>
128
 
<p>New extension classes subclass <tt class="docutils literal"><span class="pre">MapperExtension</span></tt> and are specified
129
 
using the <tt class="docutils literal"><span class="pre">extension</span></tt> mapper() argument, which is a single
130
 
<tt class="docutils literal"><span class="pre">MapperExtension</span></tt> or a list of such.   A single mapper
131
 
can maintain a chain of <tt class="docutils literal"><span class="pre">MapperExtension</span></tt> objects.  When a
132
 
particular mapping event occurs, the corresponding method 
133
 
on each <tt class="docutils literal"><span class="pre">MapperExtension</span></tt> is invoked serially, and each method
134
 
has the ability to halt the chain from proceeding further.</p>
135
140
<p>Each <tt class="docutils literal"><span class="pre">MapperExtension</span></tt> method returns the symbol
136
141
EXT_CONTINUE by default.   This symbol generally means &#8220;move
137
142
to the next <tt class="docutils literal"><span class="pre">MapperExtension</span></tt> for processing&#8221;.  For methods
193
198
<dt>**flags</dt>
194
199
<dd>extra information about the row, same as criterion in
195
200
<tt class="docutils literal"><span class="pre">create_row_processor()</span></tt> method of
196
 
<tt class="xref py py-class docutils literal"><span class="pre">MapperProperty</span></tt></dd>
 
201
<a class="reference internal" href="internals.html#sqlalchemy.orm.interfaces.MapperProperty" title="sqlalchemy.orm.interfaces.MapperProperty"><tt class="xref py py-class docutils literal"><span class="pre">MapperProperty</span></tt></a></dd>
197
202
</dl>
198
203
</dd></dl>
199
204
 
364
369
</div>
365
370
<div class="section" id="session-events">
366
371
<h2>Session Events<a class="headerlink" href="#session-events" title="Permalink to this headline">¶</a></h2>
367
 
<p>The <a class="reference internal" href="#sqlalchemy.orm.interfaces.SessionExtension" title="sqlalchemy.orm.interfaces.SessionExtension"><tt class="xref py py-class docutils literal"><span class="pre">SessionExtension</span></tt></a> applies plugin points for <a class="reference internal" href="session.html#sqlalchemy.orm.session.Session" title="sqlalchemy.orm.session.Session"><tt class="xref py py-class docutils literal"><span class="pre">Session</span></tt></a> objects:</p>
 
372
<dl class="class">
 
373
<dt id="sqlalchemy.orm.interfaces.SessionExtension">
 
374
<em class="property">class </em><tt class="descclassname">sqlalchemy.orm.interfaces.</tt><tt class="descname">SessionExtension</tt><a class="headerlink" href="#sqlalchemy.orm.interfaces.SessionExtension" title="Permalink to this definition">¶</a></dt>
 
375
<dd><p>Base implementation for <a class="reference internal" href="session.html#sqlalchemy.orm.session.Session" title="sqlalchemy.orm.session.Session"><tt class="xref py py-class docutils literal"><span class="pre">Session</span></tt></a> event hooks.</p>
 
376
<div class="admonition note">
 
377
<p class="first admonition-title">Note</p>
 
378
<p class="last"><a class="reference internal" href="#sqlalchemy.orm.interfaces.SessionExtension" title="sqlalchemy.orm.interfaces.SessionExtension"><tt class="xref py py-class docutils literal"><span class="pre">SessionExtension</span></tt></a> is deprecated.   Please
 
379
refer to <a class="reference internal" href="../core/event.html#sqlalchemy.event.listen" title="sqlalchemy.event.listen"><tt class="xref py py-func docutils literal"><span class="pre">event.listen()</span></tt></a> as well as 
 
380
<a class="reference internal" href="events.html#sqlalchemy.orm.events.SessionEvents" title="sqlalchemy.orm.events.SessionEvents"><tt class="xref py py-class docutils literal"><span class="pre">SessionEvents</span></tt></a>.</p>
 
381
</div>
 
382
<p>Subclasses may be installed into a <a class="reference internal" href="session.html#sqlalchemy.orm.session.Session" title="sqlalchemy.orm.session.Session"><tt class="xref py py-class docutils literal"><span class="pre">Session</span></tt></a> (or
 
383
<a class="reference internal" href="session.html#sqlalchemy.orm.session.sessionmaker" title="sqlalchemy.orm.session.sessionmaker"><tt class="xref py py-func docutils literal"><span class="pre">sessionmaker()</span></tt></a>) using the <tt class="docutils literal"><span class="pre">extension</span></tt> keyword
 
384
argument:</p>
368
385
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">sqlalchemy.orm.interfaces</span> <span class="kn">import</span> <span class="n">SessionExtension</span>
369
386
 
370
387
<span class="k">class</span> <span class="nc">MySessionExtension</span><span class="p">(</span><span class="n">SessionExtension</span><span class="p">):</span>
373
390
 
374
391
<span class="n">Session</span> <span class="o">=</span> <span class="n">sessionmaker</span><span class="p">(</span><span class="n">extension</span><span class="o">=</span><span class="n">MySessionExtension</span><span class="p">())</span></pre></div>
375
392
</div>
376
 
<p>The same <a class="reference internal" href="#sqlalchemy.orm.interfaces.SessionExtension" title="sqlalchemy.orm.interfaces.SessionExtension"><tt class="xref py py-class docutils literal"><span class="pre">SessionExtension</span></tt></a> instance can be
377
 
used with any number of sessions.</p>
378
 
<dl class="class">
379
 
<dt id="sqlalchemy.orm.interfaces.SessionExtension">
380
 
<em class="property">class </em><tt class="descclassname">sqlalchemy.orm.interfaces.</tt><tt class="descname">SessionExtension</tt><a class="headerlink" href="#sqlalchemy.orm.interfaces.SessionExtension" title="Permalink to this definition">¶</a></dt>
381
 
<dd><p>An extension hook object for Sessions.  Subclasses may be
382
 
installed into a Session (or sessionmaker) using the <tt class="docutils literal"><span class="pre">extension</span></tt>
383
 
keyword argument.</p>
 
393
<p>The same <a class="reference internal" href="#sqlalchemy.orm.interfaces.SessionExtension" title="sqlalchemy.orm.interfaces.SessionExtension"><tt class="xref py py-class docutils literal"><span class="pre">SessionExtension</span></tt></a> instance can be used
 
394
with any number of sessions.</p>
384
395
<dl class="method">
385
396
<dt id="sqlalchemy.orm.interfaces.SessionExtension.after_attach">
386
397
<tt class="descname">after_attach</tt><big>(</big><em>session</em>, <em>instance</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.SessionExtension.after_attach" title="Permalink to this definition">¶</a></dt>
419
430
<dl class="method">
420
431
<dt id="sqlalchemy.orm.interfaces.SessionExtension.after_commit">
421
432
<tt class="descname">after_commit</tt><big>(</big><em>session</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.SessionExtension.after_commit" title="Permalink to this definition">¶</a></dt>
422
 
<dd><p>Execute after a commit has occured.</p>
 
433
<dd><p>Execute after a commit has occurred.</p>
423
434
<p>Note that this may not be per-flush if a longer running
424
435
transaction is ongoing.</p>
425
436
</dd></dl>
441
452
state occurs.</p>
442
453
<p>This will be when the &#8216;new&#8217;, &#8216;dirty&#8217;, and &#8216;deleted&#8217; lists are in
443
454
their final state.  An actual commit() may or may not have
444
 
occured, depending on whether or not the flush started its own
 
455
occurred, depending on whether or not the flush started its own
445
456
transaction or participated in a larger transaction.</p>
446
457
</dd></dl>
447
458
 
448
459
<dl class="method">
449
460
<dt id="sqlalchemy.orm.interfaces.SessionExtension.after_rollback">
450
461
<tt class="descname">after_rollback</tt><big>(</big><em>session</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.SessionExtension.after_rollback" title="Permalink to this definition">¶</a></dt>
451
 
<dd><p>Execute after a rollback has occured.</p>
 
462
<dd><p>Execute after a rollback has occurred.</p>
452
463
<p>Note that this may not be per-flush if a longer running
453
464
transaction is ongoing.</p>
454
465
</dd></dl>
474
485
</div>
475
486
<div class="section" id="attribute-events">
476
487
<h2>Attribute Events<a class="headerlink" href="#attribute-events" title="Permalink to this headline">¶</a></h2>
477
 
<p><a class="reference internal" href="#sqlalchemy.orm.interfaces.AttributeExtension" title="sqlalchemy.orm.interfaces.AttributeExtension"><tt class="xref py py-class docutils literal"><span class="pre">AttributeExtension</span></tt></a> is used to listen for set, remove, and append
478
 
events on individual mapped attributes. It is established on an individual
479
 
mapped attribute using the <cite>extension</cite> argument, available on
480
 
<a class="reference internal" href="mapper_config.html#sqlalchemy.orm.column_property" title="sqlalchemy.orm.column_property"><tt class="xref py py-func docutils literal"><span class="pre">column_property()</span></tt></a>, <a class="reference internal" href="relationships.html#sqlalchemy.orm.relationship" title="sqlalchemy.orm.relationship"><tt class="xref py py-func docutils literal"><span class="pre">relationship()</span></tt></a>, and others:</p>
 
488
<dl class="class">
 
489
<dt id="sqlalchemy.orm.interfaces.AttributeExtension">
 
490
<em class="property">class </em><tt class="descclassname">sqlalchemy.orm.interfaces.</tt><tt class="descname">AttributeExtension</tt><a class="headerlink" href="#sqlalchemy.orm.interfaces.AttributeExtension" title="Permalink to this definition">¶</a></dt>
 
491
<dd><p>Base implementation for <tt class="xref py py-class docutils literal"><span class="pre">AttributeImpl</span></tt> event hooks, events
 
492
that fire upon attribute mutations in user code.</p>
 
493
<div class="admonition note">
 
494
<p class="first admonition-title">Note</p>
 
495
<p class="last"><a class="reference internal" href="#sqlalchemy.orm.interfaces.AttributeExtension" title="sqlalchemy.orm.interfaces.AttributeExtension"><tt class="xref py py-class docutils literal"><span class="pre">AttributeExtension</span></tt></a> is deprecated.   Please
 
496
refer to <a class="reference internal" href="../core/event.html#sqlalchemy.event.listen" title="sqlalchemy.event.listen"><tt class="xref py py-func docutils literal"><span class="pre">event.listen()</span></tt></a> as well as 
 
497
<a class="reference internal" href="events.html#sqlalchemy.orm.events.AttributeEvents" title="sqlalchemy.orm.events.AttributeEvents"><tt class="xref py py-class docutils literal"><span class="pre">AttributeEvents</span></tt></a>.</p>
 
498
</div>
 
499
<p><a class="reference internal" href="#sqlalchemy.orm.interfaces.AttributeExtension" title="sqlalchemy.orm.interfaces.AttributeExtension"><tt class="xref py py-class docutils literal"><span class="pre">AttributeExtension</span></tt></a> is used to listen for set,
 
500
remove, and append events on individual mapped attributes.
 
501
It is established on an individual mapped attribute using
 
502
the <cite>extension</cite> argument, available on
 
503
<a class="reference internal" href="mapper_config.html#sqlalchemy.orm.column_property" title="sqlalchemy.orm.column_property"><tt class="xref py py-func docutils literal"><span class="pre">column_property()</span></tt></a>, <a class="reference internal" href="relationships.html#sqlalchemy.orm.relationship" title="sqlalchemy.orm.relationship"><tt class="xref py py-func docutils literal"><span class="pre">relationship()</span></tt></a>, and
 
504
others:</p>
481
505
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">sqlalchemy.orm.interfaces</span> <span class="kn">import</span> <span class="n">AttributeExtension</span>
482
506
<span class="kn">from</span> <span class="nn">sqlalchemy.orm</span> <span class="kn">import</span> <span class="n">mapper</span><span class="p">,</span> <span class="n">relationship</span><span class="p">,</span> <span class="n">column_property</span>
483
507
 
496
520
<span class="p">})</span></pre></div>
497
521
</div>
498
522
<p>Note that the <a class="reference internal" href="#sqlalchemy.orm.interfaces.AttributeExtension" title="sqlalchemy.orm.interfaces.AttributeExtension"><tt class="xref py py-class docutils literal"><span class="pre">AttributeExtension</span></tt></a> methods
499
 
<a class="reference internal" href="#sqlalchemy.orm.interfaces.AttributeExtension.append" title="sqlalchemy.orm.interfaces.AttributeExtension.append"><tt class="xref py py-meth docutils literal"><span class="pre">append()</span></tt></a> and <a class="reference internal" href="#sqlalchemy.orm.interfaces.AttributeExtension.set" title="sqlalchemy.orm.interfaces.AttributeExtension.set"><tt class="xref py py-meth docutils literal"><span class="pre">set()</span></tt></a> need
500
 
to return the <tt class="docutils literal"><span class="pre">value</span></tt> parameter. The returned value is used as the effective
501
 
value, and allows the extension to change what is ultimately persisted.</p>
502
 
<dl class="class">
503
 
<dt id="sqlalchemy.orm.interfaces.AttributeExtension">
504
 
<em class="property">class </em><tt class="descclassname">sqlalchemy.orm.interfaces.</tt><tt class="descname">AttributeExtension</tt><a class="headerlink" href="#sqlalchemy.orm.interfaces.AttributeExtension" title="Permalink to this definition">¶</a></dt>
505
 
<dd><p>An event handler for individual attribute change events.</p>
 
523
<a class="reference internal" href="#sqlalchemy.orm.interfaces.AttributeExtension.append" title="sqlalchemy.orm.interfaces.AttributeExtension.append"><tt class="xref py py-meth docutils literal"><span class="pre">append()</span></tt></a> and
 
524
<a class="reference internal" href="#sqlalchemy.orm.interfaces.AttributeExtension.set" title="sqlalchemy.orm.interfaces.AttributeExtension.set"><tt class="xref py py-meth docutils literal"><span class="pre">set()</span></tt></a> need to return the
 
525
<tt class="docutils literal"><span class="pre">value</span></tt> parameter. The returned value is used as the
 
526
effective value, and allows the extension to change what is
 
527
ultimately persisted.</p>
506
528
<p>AttributeExtension is assembled within the descriptors associated
507
529
with a mapped class.</p>
508
530
<dl class="attribute">
540
562
</dd></dl>
541
563
 
542
564
</div>
543
 
<div class="section" id="instrumentation-events-and-re-implementation">
544
 
<h2>Instrumentation Events and Re-implementation<a class="headerlink" href="#instrumentation-events-and-re-implementation" title="Permalink to this headline">¶</a></h2>
545
 
<p><a class="reference internal" href="#sqlalchemy.orm.interfaces.InstrumentationManager" title="sqlalchemy.orm.interfaces.InstrumentationManager"><tt class="xref py py-class docutils literal"><span class="pre">InstrumentationManager</span></tt></a> can be subclassed in order to receive class
546
 
instrumentation events as well as to change how class instrumentation
547
 
proceeds. This class exists for the purposes of integration with other object
548
 
management frameworks which would like to entirely modify the instrumentation
549
 
methodology of the ORM, and is not intended for regular usage. One possible
550
 
exception is the <a class="reference internal" href="#sqlalchemy.orm.interfaces.InstrumentationManager.post_configure_attribute" title="sqlalchemy.orm.interfaces.InstrumentationManager.post_configure_attribute"><tt class="xref py py-meth docutils literal"><span class="pre">InstrumentationManager.post_configure_attribute()</span></tt></a>
551
 
method, which can be useful for adding extensions to all mapped attributes,
552
 
though a much better way to do this will be available in a future release of
553
 
SQLAlchemy.</p>
554
 
<p>For an example of <a class="reference internal" href="#sqlalchemy.orm.interfaces.InstrumentationManager" title="sqlalchemy.orm.interfaces.InstrumentationManager"><tt class="xref py py-class docutils literal"><span class="pre">InstrumentationManager</span></tt></a>, see the example
555
 
<a class="reference internal" href="examples.html#examples-instrumentation"><em>Attribute Instrumentation</em></a>.</p>
556
 
<dl class="class">
557
 
<dt id="sqlalchemy.orm.interfaces.InstrumentationManager">
558
 
<em class="property">class </em><tt class="descclassname">sqlalchemy.orm.interfaces.</tt><tt class="descname">InstrumentationManager</tt><big>(</big><em>class_</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.InstrumentationManager" title="Permalink to this definition">¶</a></dt>
559
 
<dd><p>User-defined class instrumentation extension.</p>
560
 
<p>The API for this class should be considered as semi-stable,
561
 
and may change slightly with new releases.</p>
562
 
<dl class="method">
563
 
<dt id="sqlalchemy.orm.interfaces.InstrumentationManager.__init__">
564
 
<tt class="descname">__init__</tt><big>(</big><em>class_</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.InstrumentationManager.__init__" title="Permalink to this definition">¶</a></dt>
565
 
<dd></dd></dl>
566
 
 
567
 
<dl class="method">
568
 
<dt id="sqlalchemy.orm.interfaces.InstrumentationManager.dict_getter">
569
 
<tt class="descname">dict_getter</tt><big>(</big><em>class_</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.InstrumentationManager.dict_getter" title="Permalink to this definition">¶</a></dt>
570
 
<dd></dd></dl>
571
 
 
572
 
<dl class="method">
573
 
<dt id="sqlalchemy.orm.interfaces.InstrumentationManager.dispose">
574
 
<tt class="descname">dispose</tt><big>(</big><em>class_</em>, <em>manager</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.InstrumentationManager.dispose" title="Permalink to this definition">¶</a></dt>
575
 
<dd></dd></dl>
576
 
 
577
 
<dl class="method">
578
 
<dt id="sqlalchemy.orm.interfaces.InstrumentationManager.get_instance_dict">
579
 
<tt class="descname">get_instance_dict</tt><big>(</big><em>class_</em>, <em>instance</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.InstrumentationManager.get_instance_dict" title="Permalink to this definition">¶</a></dt>
580
 
<dd></dd></dl>
581
 
 
582
 
<dl class="method">
583
 
<dt id="sqlalchemy.orm.interfaces.InstrumentationManager.initialize_instance_dict">
584
 
<tt class="descname">initialize_instance_dict</tt><big>(</big><em>class_</em>, <em>instance</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.InstrumentationManager.initialize_instance_dict" title="Permalink to this definition">¶</a></dt>
585
 
<dd></dd></dl>
586
 
 
587
 
<dl class="method">
588
 
<dt id="sqlalchemy.orm.interfaces.InstrumentationManager.install_descriptor">
589
 
<tt class="descname">install_descriptor</tt><big>(</big><em>class_</em>, <em>key</em>, <em>inst</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.InstrumentationManager.install_descriptor" title="Permalink to this definition">¶</a></dt>
590
 
<dd></dd></dl>
591
 
 
592
 
<dl class="method">
593
 
<dt id="sqlalchemy.orm.interfaces.InstrumentationManager.install_member">
594
 
<tt class="descname">install_member</tt><big>(</big><em>class_</em>, <em>key</em>, <em>implementation</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.InstrumentationManager.install_member" title="Permalink to this definition">¶</a></dt>
595
 
<dd></dd></dl>
596
 
 
597
 
<dl class="method">
598
 
<dt id="sqlalchemy.orm.interfaces.InstrumentationManager.install_state">
599
 
<tt class="descname">install_state</tt><big>(</big><em>class_</em>, <em>instance</em>, <em>state</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.InstrumentationManager.install_state" title="Permalink to this definition">¶</a></dt>
600
 
<dd></dd></dl>
601
 
 
602
 
<dl class="method">
603
 
<dt id="sqlalchemy.orm.interfaces.InstrumentationManager.instrument_attribute">
604
 
<tt class="descname">instrument_attribute</tt><big>(</big><em>class_</em>, <em>key</em>, <em>inst</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.InstrumentationManager.instrument_attribute" title="Permalink to this definition">¶</a></dt>
605
 
<dd></dd></dl>
606
 
 
607
 
<dl class="method">
608
 
<dt id="sqlalchemy.orm.interfaces.InstrumentationManager.instrument_collection_class">
609
 
<tt class="descname">instrument_collection_class</tt><big>(</big><em>class_</em>, <em>key</em>, <em>collection_class</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.InstrumentationManager.instrument_collection_class" title="Permalink to this definition">¶</a></dt>
610
 
<dd></dd></dl>
611
 
 
612
 
<dl class="method">
613
 
<dt id="sqlalchemy.orm.interfaces.InstrumentationManager.manage">
614
 
<tt class="descname">manage</tt><big>(</big><em>class_</em>, <em>manager</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.InstrumentationManager.manage" title="Permalink to this definition">¶</a></dt>
615
 
<dd></dd></dl>
616
 
 
617
 
<dl class="method">
618
 
<dt id="sqlalchemy.orm.interfaces.InstrumentationManager.manager_getter">
619
 
<tt class="descname">manager_getter</tt><big>(</big><em>class_</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.InstrumentationManager.manager_getter" title="Permalink to this definition">¶</a></dt>
620
 
<dd></dd></dl>
621
 
 
622
 
<dl class="method">
623
 
<dt id="sqlalchemy.orm.interfaces.InstrumentationManager.post_configure_attribute">
624
 
<tt class="descname">post_configure_attribute</tt><big>(</big><em>class_</em>, <em>key</em>, <em>inst</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.InstrumentationManager.post_configure_attribute" title="Permalink to this definition">¶</a></dt>
625
 
<dd></dd></dl>
626
 
 
627
 
<dl class="method">
628
 
<dt id="sqlalchemy.orm.interfaces.InstrumentationManager.remove_state">
629
 
<tt class="descname">remove_state</tt><big>(</big><em>class_</em>, <em>instance</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.InstrumentationManager.remove_state" title="Permalink to this definition">¶</a></dt>
630
 
<dd></dd></dl>
631
 
 
632
 
<dl class="method">
633
 
<dt id="sqlalchemy.orm.interfaces.InstrumentationManager.state_getter">
634
 
<tt class="descname">state_getter</tt><big>(</big><em>class_</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.InstrumentationManager.state_getter" title="Permalink to this definition">¶</a></dt>
635
 
<dd></dd></dl>
636
 
 
637
 
<dl class="method">
638
 
<dt id="sqlalchemy.orm.interfaces.InstrumentationManager.uninstall_descriptor">
639
 
<tt class="descname">uninstall_descriptor</tt><big>(</big><em>class_</em>, <em>key</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.InstrumentationManager.uninstall_descriptor" title="Permalink to this definition">¶</a></dt>
640
 
<dd></dd></dl>
641
 
 
642
 
<dl class="method">
643
 
<dt id="sqlalchemy.orm.interfaces.InstrumentationManager.uninstall_member">
644
 
<tt class="descname">uninstall_member</tt><big>(</big><em>class_</em>, <em>key</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.InstrumentationManager.uninstall_member" title="Permalink to this definition">¶</a></dt>
645
 
<dd></dd></dl>
646
 
 
647
 
</dd></dl>
648
 
 
649
 
</div>
650
565
</div>
651
566
 
652
567
    </div>
655
570
 
656
571
    <div class="bottomnav">
657
572
            Previous:
658
 
            <a href="loading.html" title="previous chapter">Relationship Loading Techniques</a>
 
573
            <a href="examples.html" title="previous chapter">Examples</a>
659
574
            Next:
660
 
            <a href="extensions/index.html" title="next chapter">ORM Extensions</a>
 
575
            <a href="exceptions.html" title="next chapter">ORM Exceptions</a>
661
576
        <div class="doc_copyright">
662
577
            &copy; <a href="../copyright.html">Copyright</a> 2007-2011, the SQLAlchemy authors and contributors.
663
578
            Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.