ÿØÿàJFIFÿþ ÿÛC       ÿÛC ÿÀÿÄÿÄ"#QrÿÄÿÄ&1!A"2qQaáÿÚ ?Øy,æ/3JæÝ¹È߲؋5êXw²±ÉyˆR”¾I0ó2—PI¾IÌÚiMö¯–þrìN&"KgX:Šíµ•nTJnLK„…@!‰-ý ùúmë;ºgµŒ&ó±hw’¯Õ@”Ü— 9ñ-ë.²1<yà‚¹ïQÐU„ہ?.’¦èûbß±©Ö«Âw*VŒ) `$‰bØÔŸ’ëXÖ-ËTÜíGÚ3ð«g Ÿ§¯—Jx„–’U/ÂÅv_s(Hÿ@TñJÑãõçn­‚!ÈgfbÓc­:él[ðQe 9ÀPLbÃãCµm[5¿ç'ªjglå‡Ûí_§Úõl-;"PkÞÞÁQâ¼_Ñ^¢SŸx?"¸¦ùY騐ÒOÈ q’`~~ÚtËU¹CڒêV  I1Áß_ÿÙ 4]c@sdZddlmZddlmZddlmZddlmZddlmZddlm Z dd lm Z dd lm Z dd lm Z dd lmZdd lmZddlmZdefdYZejjddedefdYZejjddedefdYZejjddedefdYZejjddeejdddefdYZdS(sDescriptor properties are more "auxiliary" properties that exist as configurational elements, but don't participate as actively in the load/persist ORM loop. i(t attributes(t properties(tquery(tMapperProperty(tPropComparator(t _none_seti(tevent(texc(tschema(tsql(tutil(t expressiontDescriptorPropertycBseZdZdZdZRS(sS:class:`.MapperProperty` which proxies access to a user-defined descriptor.c s;dtffdY}jdkrjtjjd}j|rj|_qjnjdkrfd}fd}fd}td|d|d|_ntj jj jjjfd d j d }|j|_ j jj|dS( Nt _ProxyImplcsbeZeZeZeZefdZdZ e dr`e j fdZ nRS(cstjjjjS(N(tgetattrtclass_tnametimplt uses_objects(tself(tmappertprop(sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR*scSs ||_dS(N(tkey(RR((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt__init__.st get_historycsj|||S(N(R(Rtstatetdict_tpassive(R(sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR3s(t__name__t __module__tFalsetaccepts_scalar_loadertTruetexpire_missingt collectiontpropertyRRthasattrRt PASSIVE_OFFR((RR(sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR %s cst|j|dS(N(tsetattrR(tobjtvalue(R(sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pytfset?scst|jdS(N(tdelattrR(R'(R(sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pytfdelBscst|jS(N(RR(R'(R(sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pytfgetEsR,R)R+cs jS(N(t_comparator_factory((RR(sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pytNttdoctoriginal_property(tobjectt descriptortNoneRRRt_is_userland_descriptorR#Rtcreate_proxied_attributetparentR0Rt class_managertinstrument_attribute(RRR tdescR)R+R,t proxy_attr((RRRsR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pytinstrument_class"s(!   N(RRt__doc__R4R0R<(((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR sssqlalchemy.orm.propertiest add_to_alltCompositePropertycBseZdZejdddZdZdZdZej dZ ej d Z e d Z d Zd Zej d ZejdZdZdejfdYZdefdYZdZRS(sDefines 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` t extensions0.7s:class:`.AttributeExtension` is deprecated in favor of the :class:`.AttributeEvents` listener interface. The :paramref:`.composite.extension` parameter will be removed in a future release.cOstt|j||_||_|jdt|_|jdt|_|jdd|_ |j d|j j |_d|kr|j d|_ntj||jdS(sQReturn 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, or any classmethod or callable which will produce a new instance of the composite object given the column values in order. :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`. :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. :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. tactive_historytdeferredtgrouptcomparator_factorytinfoN(tsuperR?Rtattrstcomposite_classtgetRRARBR4RCtpopt __class__t ComparatorRDRER tset_creation_ordert_create_descriptor(RRRGtkwargs((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyRds:    cCs$tt|j||jdS(N(RFR?R<t_setup_event_handlers(RR((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR<scCs|jdS(sInitialization which occurs after the :class:`.CompositeProperty` has been associated with its parent mapper. N(t_setup_arguments_on_columns(R((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pytdo_initscsFfd}fd}fd}t|||_dS(stCreate the Python descriptor that will serve as the access point on instances of the mapped class. cstj|}tj|}j|krgjD]}t||^q7}j|kr|jdk stj| rj ||j<|j j j |djgqn|j jdS(N(Rt instance_dicttinstance_stateRt_attribute_keysRR4Rt issupersetRHtmanagertdispatchtrefreshRI(tinstanceRRRtvalues(R(sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR,s%%cstj|}tj|}|jj}|jjtj}x,|jjD]}|||||j }qSW||j<|dkrx]j D]}t ||dqWn9x6t j |jD]\}}t |||qWdS(N(RRSRTRWRRItNO_VALUERXtsetRR4RUR&tzipt__composite_values__(RZR(RRtattrtprevioustfnR(R(sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR)s  cstj|}tj|}|jjtj}|jj}|jj|||j x!j D]}t ||dqiWdS(N( RRTRSRJRR\RWRXtremoveRRUR&R4(RZRRRaR`R(R(sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR+sN(R#R3(RR,R)R+((RsR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyRNs cCs,g|jD]}t|jj|j^q S(N(tpropsRR7RR(RR((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt_comparable_elementsscCsg}x|jD]}t|tr@|jj|dt}nYt|tjre|jj|}n4t|t j r|j }nt j d|f|j|qW|S(Nt_configure_mapperss[Composite expects Column objects or mapped attributes/attribute names as arguments, got: %r(RGt isinstancetstrR7t get_propertyRRtColumnt_columntopropertyRtInstrumentedAttributeR#tsa_exct ArgumentErrortappend(RRdR`R((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyRds  cCs,g|jD]}t|tjr |^q S(N(RGRgRRj(Rta((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pytcolumns scCscx\|jD]Q}|j|_|jrO|j|_dtfdtff|_n|j|_q WdS(swPropagate configuration arguments made on this composite to the target columns, for those that apply. RBt instrumentN(RdRARBR t strategy_keyRC(RR((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyRQs    csfd}fd}fdfd}fd}tjjd|dttjjd|dttjjd |dtd ttjjd |dtd ttjjd |dtd td S(s>Establish events that populate/expire the composite attribute.cs||dtdS(Nt is_refresh(R(Rtargs(t_load_refresh_handler(sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt load_handlerscs||dtdS(NRt(R (RRu(Rv(sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pytrefresh_handler!scs~|j}| r#j|kr#dSx!jD]}||kr-dSq-WjgjD]}|j|^qW|jProvided for userland code that uses attributes.get_history().N((((RRdRRWRRt has_changesR t non_deletedtextendRoR4tdeletedRtHistoryRH( RRRRtaddedRt has_historyRRthistR((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyRYs*      cCs|j||S(N(RD(RR((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR-ystCompositeBundlecBseZdZdZRS(cCs,||_ttj|j|j|dS(N(R#RFR?RRR(Rt property_texpr((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR}s csfd}|S(Ncs)jjgD]}||^qS(N(R#RH(trowtproc(tprocsR(sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyRs ((RRRtlabelsR((RRsR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pytcreate_row_processors(RRRR(((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR|s RLcBsbeZdZdZedZdZdZdZ e j dZ dZ dZRS( sProduce 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`. .. seealso:: :class:`.PropComparator` :class:`.ColumnOperators` :ref:`types_operators` :attr:`.TypeEngine.comparator_factory` cCs |jS(N(t__clause_element__(R((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pytclausesscCstjdt|jS(NRC(R t ClauseListRRe(R((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyRs cCstj|j|jS(N(R?RRR(R((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt_query_clause_elementscCs~|dkr.g|jjD] }d^q}n@t||jjrR|j}ntjd|j|ft|j |S(Ns)Can't UPDATE composite attribute %s to %r( R4RRURgRHR_RmRnR^Re(RR(RR[((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt_bulk_update_tupless "cCsF|jr8g|jjD]}t|jj|j^qS|jjSdS(N(t_adapt_to_entityRReRtentityR(RR((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyRes ,cCs|dkr(dgt|jj}n |j}gt|jj|D]\}}||k^qJ}|jrg|D]}|j|^qx}ntj |S(N( R4tlenRReR_R^RtadapterR tand_(RtotherR[Rptbt comparisonstx((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt__eq__s  4 %cCstj|j|S(N(R tnot_R(RR((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt__ne__sN(RRR=R4t__hash__R#RRRRR tmemoized_propertyReRR(((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyRLs    cCst|jjjd|jS(Nt.(RhR7RRR(R((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt__str__s(s0.7s:class:`.AttributeExtension` is deprecated in favor of the :class:`.AttributeEvents` listener interface. The :paramref:`.composite.extension` parameter will be removed in a future release.(RRR=R tdeprecated_paramsRR<RRRNRReRdR#RqRQRPRURR%RR-RtBundleRRRLR(((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR?Vs$  G   ; : ItConcreteInheritedPropertycBs eZdZdZdZRS(s4A '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. cCsPd}xC|jjD]2}|j|j}t|ts|j}PqqW|S(N(R4R7titerate_to_roott_propsRRgRRD(RRtcomparator_callabletmtp((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR-s csQttjfddtffdY}|_dS(Ncs&tdjjjfdS(NsgConcrete %s does not implement attribute %r at the instance level. Add this property explicitly to %s.(tAttributeErrorR7R((R(sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pytwarnstNoninheritedConcretePropcs8eZfdZfdZfdZRS(cs dS(N((tsR'R((R(sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt__set__scs dS(N((RR'(R(sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt __delete__scs|dkrjSdS(N(R4R3(RR'towner(RR(sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt__get__s (RRRRR((RR(sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyRs(RFRRR2R3(RR((RRsR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyRs (RRR=R-R(((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyRs tSynonymPropertycBsMeZddddddZejdZdZdZdZ RS(cCsxtt|j||_||_||_||_|pO|rL|jpOd|_ |rg||_ nt j |dS(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. e.g.:: class MyClass(Base): __tablename__ = 'my_table' id = Column(Integer, primary_key=True) job_status = Column(String(50)) status = synonym("job_status") :param name: the name of the existing mapped property. This can refer to the string name ORM-mapped attribute 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: **For classical mappings and mappings against an existing Table object only**. if ``True``, the :func:`.synonym` construct will locate the :class:`.Column` object upon the mapped table that would normally be associated with the attribute name of this synonym, and produce a new :class:`.ColumnProperty` that instead maps this :class:`.Column` to the alternate name given as the "name" argument of the synonym; in this way, the usual step of redefining the mapping of the :class:`.Column` to be under a different name is unnecessary. This is usually intended to be used when a :class:`.Column` is to be replaced with an attribute that also uses a descriptor, that is, in conjunction with the :paramref:`.synonym.descriptor` parameter:: my_table = Table( "my_table", metadata, Column('id', Integer, primary_key=True), Column('job_status', String(50)) ) class MyClass(object): @property def _job_status_descriptor(self): return "Status: %s" % self._job_status mapper( MyClass, my_table, properties={ "job_status": synonym( "_job_status", map_column=True, descriptor=MyClass._job_status_descriptor) } ) Above, the attribute named ``_job_status`` is automatically mapped to the ``job_status`` column:: >>> j1 = MyClass() >>> j1._job_status = "employed" >>> j1.job_status Status: employed When using Declarative, in order to provide a descriptor in conjunction with a synonym, use the :func:`sqlalchemy.ext.declarative.synonym_for` helper. However, note that the :ref:`hybrid properties ` feature should usually be preferred, particularly when redefining attribute behavior. :param info: Optional data dictionary which will be populated into the :attr:`.InspectionAttr.info` attribute of this object. .. versionadded:: 1.0.0 :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` - Overview of synonyms :func:`.synonym_for` - a helper oriented towards Declarative :ref:`mapper_hybrids` - The Hybrid Attribute extension provides an updated approach to augmenting attribute behavior more flexibly than can be achieved with synonyms. N( RFRRRt map_columnR3RDR=R4R0RER RM(RRRR3RDR0RE((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyRsl     cCsmt|jj|j}t|d s;t|jt rftj d|jjj |j|fn|jS(NR#sGsynonym() attribute "%s.%s" only supports ORM mapped attributes, got %r( RR7RRR$RgR#RRmtInvalidRequestErrorR(RR`((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt_proxied_propertys"cCs=|j}|jr'|j||}n|j||}|S(N(RRD(RRRtcomp((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR-s   cOs+t|jj|j}|jj||S(N(RR7RRRR(RtargtkwR`((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyRscCs|jr|j|jjkrItjd|j|jj|jfnp|jj|j|jkr|j|jj|jj|jkrtjd|j|j|j|jfnt j |jj|j}|j |j|d|dt |j|_ n||_dS(Ns>Can't compile synonym '%s': no column on table '%s' named '%s'spCan't call map_column=True for synonym %r=%r, a ColumnProperty already exists keyed to the name %r for column %rtinitt setparent(RRtpersist_selectabletcRmRnRt descriptionRkRtColumnPropertyt_configure_propertyR t_mapped_by_synonymR7(RR7RR((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt set_parents(    %N( RRR4RR RRR-RR(((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyRs t s0.7s:func:`.comparable_property` is deprecated and will be removed in a future release. Please refer to the :mod:`~sqlalchemy.ext.hybrid` extension.tComparablePropertycBs)eZdZddddZdZRS(s;Instruments a Python property for use in query expressions.cCsftt|j||_||_|p=|r:|jp=d|_|rU||_nt j |dS(s Provides a method of applying a :class:`.PropComparator` to any Python descriptor attribute. 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. :param info: Optional data dictionary which will be populated into the :attr:`.InspectionAttr.info` attribute of this object. .. versionadded:: 1.0.0 N( RFRRR3RDR=R4R0RER RM(RRDR3R0RE((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyRsB   cCs|j||S(N(RD(RR((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyR-sN(RRR=R4RR-(((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyRsIN(R=R/RRRt interfacesRRR RRRRmRR R R t langhelperstdependency_forR R?RRtdeprecated_clsR(((sR/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/descriptor_props.pyt s2:5