ó
H`¾Tc           @   sN  d  Z  d d l m Z m Z d d l m Z d d l m Z d d l m Z m Z m	 Z
 m Z m Z d d l m Z d d l m Z d d	 l m Z d
 e f d „  ƒ  YZ e j j d ƒ d e f d „  ƒ  Yƒ Z e j j d ƒ d e f d „  ƒ  Yƒ Z e j j d ƒ d e f d „  ƒ  Yƒ Z e j j d ƒ d e f d „  ƒ  Yƒ Z d S(   sŸ   Descriptor properties are more "auxiliary" properties
that exist as configurational elements, but don't participate
as actively in the load/persist ORM loop.

i   (   t   MapperPropertyt   PropComparator(   t	   _none_set(   t
   attributesi   (   t   utilt   sqlt   exct   eventt   schema(   t
   expression(   t
   properties(   t   queryt   DescriptorPropertyc           B   s   e  Z d  Z d Z d „  Z RS(   sS   :class:`.MapperProperty` which proxies access to a
        user-defined descriptor.c      	      s8  ˆ ‰ d t  f ‡ f d †  ƒ  Y} ˆ j d  k rg t ˆ  j ˆ j d  ƒ } ˆ  j | ƒ rg | ˆ _ qg n  ˆ j d  k rÄ ‡ f d †  } ‡ f d †  } ‡ f d †  } t d | d | d | ƒ ˆ _ n  t j	 ˆ j ƒ ˆ j
 j ˆ j ˆ j ‡  ‡ f d	 †  d
 ˆ j d ˆ ƒ} | ˆ j ƒ | _ ˆ  j j ˆ j | ƒ d  S(   Nt
   _ProxyImplc              sJ   e  Z e Z e Z e Z d  „  Z e ˆ  d ƒ rH e	 j
 ‡  f d † Z n  RS(   c         S   s   | |  _  d  S(   N(   t   key(   t   selfR   (    (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt   __init__%   s    t   get_historyc            s   ˆ  j  | | | ƒ S(   N(   R   (   R   t   statet   dict_t   passive(   t   prop(    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR   )   s    (   t   __name__t
   __module__t   Falset   accepts_scalar_loadert   Truet   expire_missingt
   collectionR   t   hasattrR   t   PASSIVE_OFFR   (    (   R   (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR       s   	c            s   t  |  ˆ  j | ƒ d  S(   N(   t   setattrt   name(   t   objt   value(   R   (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt   fset3   s    c            s   t  |  ˆ  j ƒ d  S(   N(   t   delattrR    (   R!   (   R   (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt   fdel6   s    c            s   t  |  ˆ  j ƒ S(   N(   t   getattrR    (   R!   (   R   (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt   fget9   s    R'   R#   R%   c              s   ˆ j  ˆ  ƒ S(   N(   t   _comparator_factory(    (   t   mapperR   (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt   <lambda>G   s    t   doct   original_property(   t   objectt
   descriptort   NoneR&   t   class_R   t   _is_userland_descriptort   propertyR   t   create_proxied_attributet   parentR+   t   implt   class_managert   instrument_attribute(   R   R)   R   t   descR#   R%   R'   t
   proxy_attr(    (   R)   R   R   se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt   instrument_class   s0    				N(   R   R   t   __doc__R/   R+   R:   (    (    (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR      s   s   sqlalchemy.orm.propertiest   CompositePropertyc           B   sÙ   e  Z d  Z d „  Z d „  Z d „  Z d „  Z e j d „  ƒ Z	 e j d „  ƒ Z
 e d „  ƒ Z d „  Z d	 „  Z e j d
 „  ƒ Z e j d „ Z d „  Z d e j f d „  ƒ  YZ d e f d „  ƒ  YZ d „  Z RS(   sö   Defines a "composite" mapped attribute, representing a collection
    of columns as one attribute.

    :class:`.CompositeProperty` is constructed using the :func:`.composite`
    function.

    .. seealso::

        :ref:`mapper_composite`

    c         O   s¨   | |  _  | |  _ | j d t ƒ |  _ | j d t ƒ |  _ | j d d ƒ |  _ | j d |  j	 j
 ƒ |  _ d | k r | j d ƒ |  _ n  t j |  ƒ |  j ƒ  d S(   s©  Return a composite column-based property for use with a Mapper.

        See the mapping documentation section :ref:`mapper_composite` for a
        full usage example.

        The :class:`.MapperProperty` returned by :func:`.composite`
        is the :class:`.CompositeProperty`.

        :param class\_:
          The "composite type" class.

        :param \*cols:
          List of Column objects to be mapped.

        :param active_history=False:
          When ``True``, indicates that the "previous" value for a
          scalar attribute should be loaded when replaced, if not
          already loaded.  See the same flag on :func:`.column_property`.

          .. versionchanged:: 0.7
              This flag specifically becomes meaningful
              - previously it was a placeholder.

        :param group:
          A group name for this property when marked as deferred.

        :param deferred:
          When True, the column property is "deferred", meaning that it does
          not load immediately, and is instead loaded when the attribute is
          first accessed on an instance.  See also
          :func:`~sqlalchemy.orm.deferred`.

        :param comparator_factory:  a class which extends
          :class:`.CompositeProperty.Comparator` which provides custom SQL
          clause generation for comparison operations.

        :param doc:
          optional string that will be applied as the doc on the
          class-bound descriptor.

        :param info: Optional data dictionary which will be populated into the
            :attr:`.MapperProperty.info` attribute of this object.

            .. versionadded:: 0.8

        :param extension:
          an :class:`.AttributeExtension` instance,
          or list of extensions, which will be prepended to the list of
          attribute listeners for the resulting descriptor placed on the
          class.  **Deprecated.**  Please see :class:`.AttributeEvents`.

        t   active_historyt   deferredt   groupt   comparator_factoryt   infoN(   t   attrst   composite_classt   getR   R=   R>   R/   R?   t   popt	   __class__t
   ComparatorR@   RA   R   t   set_creation_ordert   _create_descriptor(   R   R0   RB   t   kwargs(    (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR   ]   s    6			c         C   s$   t  t |  ƒ j | ƒ |  j ƒ  d  S(   N(   t   superR<   R:   t   _setup_event_handlers(   R   R)   (    (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR:       s    c         C   s   |  j  ƒ  d S(   s   Initialization which occurs after the :class:`.CompositeProperty`
        has been associated with its parent mapper.

        N(   t   _setup_arguments_on_columns(   R   (    (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt   do_init¤   s    c            sF   ‡  f d †  } ‡  f d †  } ‡  f d †  } t  | | | ƒ ˆ  _ d S(   st   Create the Python descriptor that will serve as
        the access point on instances of the mapped class.

        c            sÎ   t  j |  ƒ } t  j |  ƒ } ˆ  j | k r» g  ˆ  j D] } t |  | ƒ ^ q7 } ˆ  j | k r» | j d  k	 s€ t j | ƒ r» ˆ  j	 | Œ  | ˆ  j <| j
 j j | d  ˆ  j g ƒ q» n  | j ˆ  j d  ƒ S(   N(   R   t   instance_dictt   instance_stateR   t   _attribute_keysR&   R/   R   t
   issupersetRC   t   managert   dispatcht   refreshRD   (   t   instanceR   R   R   t   values(   R   (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR'   ±   s    "%c            sò   t  j |  ƒ } t  j |  ƒ } | j ˆ  j } | j ˆ  j t  j ƒ } x, | j j D] } | | | | | j	 ƒ } qS W| | ˆ  j <| d  k rµ x] ˆ  j D] } t |  | d  ƒ q˜ Wn9 x6 t ˆ  j | j ƒ  ƒ D] \ } } t |  | | ƒ qÎ Wd  S(   N(   R   RO   RP   RS   R   RD   t   NO_VALUERT   t   setR5   R/   RQ   R   t   zipt   __composite_values__(   RV   R"   R   R   t   attrt   previoust   fnR   (   R   (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR#   Ì   s    c            s‡   t  j |  ƒ } t  j |  ƒ } | j ˆ  j t  j ƒ } | j ˆ  j } | j j | | | j	 ƒ x! ˆ  j
 D] } t |  | d  ƒ qi Wd  S(   N(   R   RP   RO   RE   R   RX   RS   RT   t   removeR5   RQ   R   R/   (   RV   R   R   R]   R\   R   (   R   (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR%   Ý   s    N(   R2   R.   (   R   R'   R#   R%   (    (   R   se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyRI   «   s    	c         C   s,   g  |  j  D] } t |  j j | j ƒ ^ q
 S(   N(   t   propsR&   R4   R0   R   (   R   R   (    (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt   _comparable_elementsè   s    c         C   s®   g  } x¡ |  j  D]– } t | t ƒ r@ |  j j | d t ƒ} nY t | t j ƒ re |  j j | } n4 t | t	 j
 ƒ rƒ | j } n t j d | f ƒ ‚ | j | ƒ q W| S(   Nt   _configure_mapperss[   Composite expects Column objects or mapped attributes/attribute names as arguments, got: %r(   RB   t
   isinstancet   strR4   t   get_propertyR   R   t   Columnt   _columntopropertyR   t   InstrumentedAttributeR2   t   sa_exct   ArgumentErrort   append(   R   R`   R\   R   (    (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR`   ï   s    	c         C   s,   g  |  j  D] } t | t j ƒ r
 | ^ q
 S(   N(   RB   Rc   R   Rf   (   R   t   a(    (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt   columns  s    c         C   si   xb |  j  D]W } |  j | _ |  j rU |  j | _ | j d t f d t f ƒ | _ n  |  j | _ q
 Wd S(   sw   Propagate configuration arguments made on this composite
        to the target columns, for those that apply.

        R>   t
   instrumentN(   R`   R=   R>   t   _strategy_lookupR   t   strategy_classR?   (   R   R   (    (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyRM     s    		c            sÏ   ‡  f d †  } ‡  f d †  } ‡  f d †  } t  j ˆ  j d | d t ƒt  j ˆ  j d | d t ƒt  j ˆ  j d | d t d t ƒt  j ˆ  j d	 | d t d t ƒt  j ˆ  j d
 | d t d t ƒd S(   s>   Establish events that populate/expire the composite attribute.c            sw   |  j  } ˆ  j | k r d  Sx! ˆ  j D] } | | k r& d  Sq& Wˆ  j g  ˆ  j D] } |  j  | ^ qP Œ  | ˆ  j <d  S(   N(   t   dictR   RQ   RC   (   R   t   argsR   t   kR   (   R   (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt   load_handler  s    	c            sA   | d  k s$ t ˆ  j ƒ j | ƒ r= |  j j ˆ  j d  ƒ n  d  S(   N(   R/   RY   RQ   t   intersectionRq   RE   R   (   R   t   keys(   R   (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt   expire_handler*  s    $c            s   | j  j ˆ  j d ƒ d S(   sê   After an insert or update, some columns may be expired due
            to server side defaults, or re-populated due to client side
            defaults.  Pop out the composite value here so that it
            recreates.

            N(   Rq   RE   R   R/   (   R)   t
   connectionR   (   R   (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt   insert_update_handler.  s    t   after_insertt   rawt   after_updatet   loadt	   propagateRU   t   expireN(   R   t   listenR4   R   (   R   Rt   Rw   Ry   (    (   R   se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyRL     s    
c         C   s   g  |  j  D] } | j ^ q
 S(   N(   R`   R   (   R   R   (    (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyRQ   E  s    c         C   s  g  } g  } t  } x£ |  j D]˜ } | j } | j | j j | | ƒ }	 |	 j ƒ  r\ t } n  |	 j ƒ  }
 |
 r~ | j	 |
 ƒ n | j
 d ƒ |	 j r§ | j	 |	 j ƒ q | j
 d ƒ q W| ré t j |  j | Œ  g d |  j | Œ  g ƒ St j d |  j | Œ  g d ƒ Sd S(   s>   Provided for userland code that uses attributes.get_history().N(    (    (    (   R   R`   R   RS   R5   R   t   has_changesR   t   non_deletedt   extendRk   R/   t   deletedR   t   HistoryRC   (   R   R   R   R   t   addedR„   t   has_historyR   R   t   histR‚   (    (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR   K  s,    			c         C   s   |  j  |  | ƒ S(   N(   R@   (   R   R)   (    (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR(   m  s    t   CompositeBundlec           B   s   e  Z d  „  Z d „  Z RS(   c         C   s,   | |  _  t t j |  ƒ j | j | Œ d  S(   N(   R2   RK   R<   R‰   R   R   (   R   R2   t   expr(    (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR   q  s    	c            s   ‡  ‡ f d †  } | S(   Nc            s,   ˆ  j  j g  ˆ D] } | |  | ƒ ^ q Œ  S(   N(   R2   RC   (   t   rowt   resultt   proc(   R   t   procs(    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR   w  s    	(    (   R   R   RŽ   t   labelsR   (    (   R   RŽ   se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt   create_row_processorv  s    (   R   R   R   R   (    (    (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR‰   p  s   	RG   c           B   sY   e  Z d  Z d Z e d „  ƒ Z d „  Z d „  Z e	 j
 d „  ƒ Z d „  Z d „  Z RS(   s¬  Produce boolean, comparison, and other operators for
        :class:`.CompositeProperty` attributes.

        See the example in :ref:`composite_operations` for an overview
        of usage , as well as the documentation for :class:`.PropComparator`.

        See also:

        :class:`.PropComparator`

        :class:`.ColumnOperators`

        :ref:`types_operators`

        :attr:`.TypeEngine.comparator_factory`

        c         C   s
   |  j  ƒ  S(   N(   t   __clause_element__(   R   (    (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt   clauses‘  s    c         C   s   t  j d t |  j Œ S(   NR?   (   R	   t
   ClauseListR   Ra   (   R   (    (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR‘   •  s    	c         C   s   t  j |  j |  j ƒ  ƒ S(   N(   R<   R‰   R   R‘   (   R   (    (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt   _query_clause_element™  s    c         C   sF   |  j  r8 g  |  j j D] } t |  j  j | j ƒ ^ q S|  j j Sd  S(   N(   t   _adapt_to_entityR   Ra   R&   t   entityR   (   R   R   (    (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyRa     s    	,c         C   s£   | d  k r( d  g t |  j j ƒ } n | j ƒ  } g  t |  j j | ƒ D] \ } } | | k ^ qJ } |  j r– g  | D] } |  j | ƒ ^ qx } n  t j	 | Œ  S(   N(
   R/   t   lenR   Ra   R[   RZ   R•   t   adapterR   t   and_(   R   t   otherRW   Rl   t   bt   comparisonst   x(    (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt   __eq__©  s    1	%c         C   s   t  j |  j | ƒ ƒ S(   N(   R   t   not_Rž   (   R   Rš   (    (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt   __ne__¶  s    N(   R   R   R;   R/   t   __hash__R2   R’   R‘   R”   R   t   memoized_propertyRa   Rž   R    (    (    (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyRG   |  s   			c         C   s   t  |  j j j ƒ d |  j S(   Nt   .(   Rd   R4   R0   R   R   (   R   (    (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt   __str__¹  s    (   R   R   R;   R   R:   RN   RI   R   R¢   Ra   R`   R2   Rm   RM   RL   RQ   R   R   R   R(   R   t   BundleR‰   R   RG   R¤   (    (    (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR<   O   s    	C			=		1"	=t   ConcreteInheritedPropertyc           B   s    e  Z d  Z d „  Z d „  Z RS(   s4  A 'do nothing' :class:`.MapperProperty` that disables
    an attribute on a concrete subclass that is only present
    on the inherited mapper, not the concrete classes' mapper.

    Cases where this occurs include:

    * When the superclass mapper is mapped against a
      "polymorphic union", which includes all attributes from
      all subclasses.
    * When a relationship() is configured on an inherited mapper,
      but not on the subclass mapper.  Concrete mappers require
      that relationship() is configured explicitly on each
      subclass.

    c         C   sP   d  } xC |  j j ƒ  D]2 } | j |  j } t | t ƒ s | j } Pq q W| S(   N(   R/   R4   t   iterate_to_roott   _propsR   Rc   R¦   R@   (   R   R)   t   comparator_callablet   mt   p(    (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR(   Ï  s    	c            s>   ‡ f d †  ‰  d t  f ‡  ‡ f d †  ƒ  Y} | ƒ  ˆ _ d  S(   Nc              s&   t  d ˆ  j ˆ  j ˆ  j f ƒ ‚ d  S(   Nsg   Concrete %s does not implement attribute %r at the instance level.  Add this property explicitly to %s.(   t   AttributeErrorR4   R   (    (   R   (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt   warnÚ  s    t   NoninheritedConcretePropc              s8   e  Z ‡  f d  †  Z ‡  f d †  Z ‡ ‡  f d †  Z RS(   c            s   ˆ  ƒ  d  S(   N(    (   t   sR!   R"   (   R­   (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt   __set__á  s    c            s   ˆ  ƒ  d  S(   N(    (   R¯   R!   (   R­   (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt
   __delete__ä  s    c            s   | d  k r ˆ  j Sˆ ƒ  d  S(   N(   R/   R.   (   R¯   R!   t   owner(   R   R­   (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt   __get__ç  s    (   R   R   R°   R±   R³   (    (   R­   R   (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR®   à  s   (   R-   R.   (   R   R®   (    (   R­   R   se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR   Ù  s    (   R   R   R;   R(   R   (    (    (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR¦   ½  s   	
t   SynonymPropertyc           B   sA   e  Z d d d d d  „ Z e j d „  ƒ Z d „  Z d „  Z RS(   c         C   sS   | |  _  | |  _ | |  _ | |  _ | p< | r9 | j p< d |  _ t j |  ƒ d S(   s	  Denote an attribute name as a synonym to a mapped property,
        in that the attribute will mirror the value and expression behavior
        of another attribute.

        :param name: the name of the existing mapped property.  This
          can refer to the string name of any :class:`.MapperProperty`
          configured on the class, including column-bound attributes
          and relationships.

        :param descriptor: a Python :term:`descriptor` that will be used
          as a getter (and potentially a setter) when this attribute is
          accessed at the instance level.

        :param map_column: if ``True``, the :func:`.synonym` construct will
          locate the existing named :class:`.MapperProperty` based on the
          attribute name of this :func:`.synonym`, and assign it to a new
          attribute linked to the name of this :func:`.synonym`.
          That is, given a mapping like::

                class MyClass(Base):
                    __tablename__ = 'my_table'

                    id = Column(Integer, primary_key=True)
                    job_status = Column(String(50))

                    job_status = synonym("_job_status", map_column=True)

          The above class ``MyClass`` will now have the ``job_status``
          :class:`.Column` object mapped to the attribute named
          ``_job_status``, and the attribute named ``job_status`` will refer
          to the synonym itself.  This feature is typically used in
          conjunction with the ``descriptor`` argument in order to link a
          user-defined descriptor as a "wrapper" for an existing column.

        :param comparator_factory: A subclass of :class:`.PropComparator`
          that will provide custom comparison behavior at the SQL expression
          level.

          .. note::

            For the use case of providing an attribute which redefines both
            Python-level and SQL-expression level behavior of an attribute,
            please refer to the Hybrid attribute introduced at
            :ref:`mapper_hybrids` for a more effective technique.

        .. seealso::

            :ref:`synonyms` - examples of functionality.

            :ref:`mapper_hybrids` - Hybrids provide a better approach for
            more complicated attribute-wrapping schemes than synonyms.

        N(	   R    t
   map_columnR.   R@   R;   R/   R+   R   RH   (   R   R    Rµ   R.   R@   R+   (    (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR   ñ  s    9				c         C   s   t  |  j j |  j ƒ j S(   N(   R&   R4   R0   R    R2   (   R   (    (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt   _proxied_property5  s    c         C   s=   |  j  } |  j r' |  j | | ƒ } n | j | | ƒ } | S(   N(   R¶   R@   (   R   R)   R   t   comp(    (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR(   9  s
    		c         C   s  |  j  r|  j | j j k rI t j d |  j | j j |  j f ƒ ‚ np | j j |  j | j k r¹ | j | j j |  j j |  j k r¹ t j d |  j |  j |  j |  j f ƒ ‚ n  t	 j
 | j j |  j ƒ } | j |  j | d | d t ƒ|  j | _ n  | |  _ d  S(   Ns>   Can't compile synonym '%s': no column on table '%s' named '%s'sp   Can't call map_column=True for synonym %r=%r, a ColumnProperty already exists keyed to the name %r for column %rt   initt	   setparent(   Rµ   R   t   mapped_tablet   cRi   Rj   R    t   descriptionRg   R
   t   ColumnPropertyt   _configure_propertyR   t   _mapped_by_synonymR4   (   R   R4   R¸   R«   (    (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt
   set_parentB  s(    	"%N(	   R   R   R/   R   R   R¢   R¶   R(   RÀ   (    (    (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR´   î  s   B		t   ComparablePropertyc           B   s&   e  Z d  Z d d d „ Z d „  Z RS(   s;   Instruments a Python property for use in query expressions.c         C   sA   | |  _  | |  _ | p* | r' | j p* d |  _ t j |  ƒ d S(   s·	  Provides a method of applying a :class:`.PropComparator`
        to any Python descriptor attribute.

        .. versionchanged:: 0.7
            :func:`.comparable_property` is superseded by
            the :mod:`~sqlalchemy.ext.hybrid` extension.  See the example
            at :ref:`hybrid_custom_comparators`.

        Allows any Python descriptor to behave like a SQL-enabled
        attribute when used at the class level in queries, allowing
        redefinition of expression operator behavior.

        In the example below we redefine :meth:`.PropComparator.operate`
        to wrap both sides of an expression in ``func.lower()`` to produce
        case-insensitive comparison::

            from sqlalchemy.orm import comparable_property
            from sqlalchemy.orm.interfaces import PropComparator
            from sqlalchemy.sql import func
            from sqlalchemy import Integer, String, Column
            from sqlalchemy.ext.declarative import declarative_base

            class CaseInsensitiveComparator(PropComparator):
                def __clause_element__(self):
                    return self.prop

                def operate(self, op, other):
                    return op(
                        func.lower(self.__clause_element__()),
                        func.lower(other)
                    )

            Base = declarative_base()

            class SearchWord(Base):
                __tablename__ = 'search_word'
                id = Column(Integer, primary_key=True)
                word = Column(String)
                word_insensitive = comparable_property(lambda prop, mapper:
                                CaseInsensitiveComparator(
                                    mapper.c.word, mapper)
                            )


        A mapping like the above allows the ``word_insensitive`` attribute
        to render an expression like::

            >>> print SearchWord.word_insensitive == "Trucks"
            lower(search_word.word) = lower(:lower_1)

        :param comparator_factory:
          A PropComparator subclass or factory that defines operator behavior
          for this property.

        :param descriptor:
          Optional when used in a ``properties={}`` declaration.  The Python
          descriptor or property to layer comparison behavior on top of.

          The like-named descriptor will be automatically retrieved from the
          mapped class if left blank in a ``properties`` declaration.

        N(   R.   R@   R;   R/   R+   R   RH   (   R   R@   R.   R+   (    (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR   c  s    ?		c         C   s   |  j  |  | ƒ S(   N(   R@   (   R   R)   (    (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR(   §  s    N(   R   R   R;   R/   R   R(   (    (    (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyRÁ   _  s   DN(   R;   t
   interfacesR    R   R   R   t    R   R   R   Ri   R   R   R	   R
   R   R   t   langhelperst   dependency_forR<   R¦   R´   RÁ   (    (    (    se   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt   <module>   s"   (8ÿ n0p