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

« back to all changes in this revision

Viewing changes to doc/orm/extensions/associationproxy.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:
7
7
        
8
8
        <title>
9
9
                Association Proxy
10
 
             &mdash; SQLAlchemy 0.6.8 Documentation</title>
 
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="ORM Extensions" href="index.html" />
32
32
        <link rel="next" title="Declarative" href="declarative.html" />
33
33
        <link rel="prev" title="ORM Extensions" href="index.html" />
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
 
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
                » <a href="index.html" title="ORM Extensions">ORM Extensions</a>
78
78
        » 
375
375
<dl class="function">
376
376
<dt id="sqlalchemy.ext.associationproxy.association_proxy">
377
377
<tt class="descclassname">sqlalchemy.ext.associationproxy.</tt><tt class="descname">association_proxy</tt><big>(</big><em>target_collection</em>, <em>attr</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.ext.associationproxy.association_proxy" title="Permalink to this definition">¶</a></dt>
378
 
<dd><p>Return a Python property implementing a view of <em>attr</em> over a collection.</p>
 
378
<dd><p>Return a Python property implementing a view of a target
 
379
attribute which references an attribute on members of the 
 
380
target.</p>
379
381
<p>Implements a read/write view over an instance&#8217;s <em>target_collection</em>,
380
382
extracting <em>attr</em> from each member of the collection.  The property acts
381
383
somewhat like this list comprehension:</p>
385
387
<p>Unlike the list comprehension, the collection returned by the property is
386
388
always in sync with <em>target_collection</em>, and mutations made to either
387
389
collection will be reflected in both.</p>
 
390
<p>The association proxy also works with scalar attributes, which in
 
391
turn reference scalar attributes or collections.</p>
388
392
<p>Implements a Python property representing a relationship as a collection of
389
 
simpler values.  The proxied property will mimic the collection type of
 
393
simpler values, or a scalar value.  The proxied property will mimic the collection type of
390
394
the target (list, dict or set), or, in the case of a one to one relationship,
391
395
a simple scalar value.</p>
392
396
<table class="docutils field-list" frame="void" rules="none">
396
400
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
397
401
<li><strong>target_collection</strong> &#8211; Name of the relationship attribute we&#8217;ll proxy to,
398
402
usually created with <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>.</li>
399
 
<li><strong>attr</strong> &#8211; <p>Attribute on the associated instances we&#8217;ll proxy for.</p>
 
403
<li><strong>attr</strong> &#8211; <p>Attribute on the associated instance or instances we&#8217;ll proxy for.</p>
400
404
<p>For example, given a target collection of [obj1, obj2], a list created
401
405
by this proxy property would look like [getattr(obj1, <em>attr</em>),
402
406
getattr(obj2, <em>attr</em>)]</p>
492
496
<dd></dd></dl>
493
497
 
494
498
<dl class="attribute">
 
499
<dt id="sqlalchemy.ext.associationproxy.AssociationProxy.scalar">
 
500
<tt class="descname">scalar</tt><a class="headerlink" href="#sqlalchemy.ext.associationproxy.AssociationProxy.scalar" title="Permalink to this definition">¶</a></dt>
 
501
<dd></dd></dl>
 
502
 
 
503
<dl class="attribute">
495
504
<dt id="sqlalchemy.ext.associationproxy.AssociationProxy.target_class">
496
505
<tt class="descname">target_class</tt><a class="headerlink" href="#sqlalchemy.ext.associationproxy.AssociationProxy.target_class" title="Permalink to this definition">¶</a></dt>
497
506
<dd><p>The class the proxy is attached to.</p>