Ñò Š„[Jc @ sÞ d Z d d k Z d d k Z d d k Z d d k l Z d d k l Z d d k l Z d d k l Z d „ Z d e f d „ ƒ YZ d e f d „ ƒ YZ e i d ƒ Z d e f d „ ƒ YZ d e f d „ ƒ YZ d S( sõ Contain the ``AssociationProxy`` class. The ``AssociationProxy`` is a Python property object which provides transparent proxied access to the endpoint of an association object. See the example ``examples/association/proxied_association.py``. iÿÿÿÿN( t exceptions( t orm( t util( t collectionsc K s t | | | S( sr Return a Python property implementing a view of *attr* over a collection. Implements a read/write view over an instance's *target_collection*, extracting *attr* from each member of the collection. The property acts somewhat like this list comprehension:: [getattr(member, *attr*) for member in getattr(instance, *target_collection*)] Unlike the list comprehension, the collection returned by the property is always in sync with *target_collection*, and mutations made to either collection will be reflected in both. Implements a Python property representing a relation as a collection of simpler values. The proxied property will mimic the collection type of the target (list, dict or set), or, in the case of a one to one relation, a simple scalar value. :param target_collection: Name of the relation attribute we'll proxy to, usually created with :func:`~sqlalchemy.orm.relation`. :param attr: Attribute on the associated instances we'll proxy for. For example, given a target collection of [obj1, obj2], a list created by this proxy property would look like [getattr(obj1, *attr*), getattr(obj2, *attr*)] If the relation is one-to-one or otherwise uselist=False, then simply: getattr(obj, *attr*) :param creator: optional. When new items are added to this proxied collection, new instances of the class collected by the target collection will be created. For list and set collections, the target class constructor will be called with the 'value' for the new instance. For dict types, two arguments are passed: key and value. If you want to construct instances differently, supply a *creator* function that takes arguments as above and returns instances. For scalar relations, creator() will be called if the target is None. If the target is present, set operations are proxied to setattr() on the associated object. If you have an associated object with multiple attributes, you may set up multiple association proxies mapping to different attributes. See the unit tests for examples, and for examples of how creator() functions can be used to construct the scalar relation on-demand in this situation. :param \*\*kw: Passes along any other keyword arguments to :class:`AssociationProxy`. ( t AssociationProxy( t target_collectiont attrt kw( ( sC /usr/lib/python2.6/site-packages/sqlalchemy/ext/associationproxy.pyt association_proxy s 8R c B s’ e Z d Z d d d d d „ Z d „ Z d „ Z e e ƒ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z RS( sD A descriptor that presents a read/write view of an object attribute.c C sz | | _ | | _ | | _ | | _ | | _ | | _ d | _ d | _ d t | ƒ i | t | ƒ f | _ d | _ d S( sª Arguments are: target_collection Name of the collection we'll proxy to, usually created with 'relation()' in a mapper setup. attr Attribute on the collected instances we'll proxy for. For example, given a target collection of [obj1, obj2], a list created by this proxy property would look like [getattr(obj1, attr), getattr(obj2, attr)] creator Optional. When new items are added to this proxied collection, new instances of the class collected by the target collection will be created. For list and set collections, the target class constructor will be called with the 'value' for the new instance. For dict types, two arguments are passed: key and value. If you want to construct instances differently, supply a 'creator' function that takes arguments as above and returns instances. getset_factory Optional. Proxied attribute access is automatically handled by routines that get and set values based on the `attr` argument for this proxy. If you would like to customize this behavior, you may supply a `getset_factory` callable that produces a tuple of `getter` and `setter` functions. The factory is called with two arguments, the abstract type of the underlying collection and this proxy instance. proxy_factory Optional. The type of collection to emulate is determined by sniffing the target collection. If your collection type can't be determined by duck typing or you'd like to use a different collection implementation, you may supply a factory function to produce those collections. Only applicable to non-scalar relations. proxy_bulk_set Optional, use with proxy_factory. See the _set() method for details. s _%s_%s_%sN( R t value_attrt creatort getset_factoryt proxy_factoryt proxy_bulk_sett Nonet scalart owning_classt typet __name__t idt keyt collection_class( t selfR R R R R R ( ( sC /usr/lib/python2.6/site-packages/sqlalchemy/ext/associationproxy.pyt __init__P s . "c C s t i | i ƒ i | i ƒ S( N( R t class_mapperR t get_propertyR ( R ( ( sC /usr/lib/python2.6/site-packages/sqlalchemy/ext/associationproxy.pyt _get_property‹ s c C s | i ƒ i i S( s# The class the proxy is attached to.( R t mappert class_( R ( ( sC /usr/lib/python2.6/site-packages/sqlalchemy/ext/associationproxy.pyt target_class s c C s | i ƒ i S( N( R t uselist( R ( ( sC /usr/lib/python2.6/site-packages/sqlalchemy/ext/associationproxy.pyt _target_is_scalar” s c s" | i ‰ ~ ‡ ‡ f d † } | S( Nc s6 ˆ ƒ } | d j o t i d ƒ ‚ n t | ˆ ƒ S( Ns<