σ ΓΜ4]c@sydZddlmZddlmZdefd„ƒYZiZd d„Zd d„Z d „Z d „Z d „Z d S( sŸThe :class:`.Annotated` class and related routines; creates hash-equivalent copies of SQL constructs which contain context-specific markers and associations. i(t operatorsi(tutilt AnnotatedcBs}eZdZd„Zd„Zd„Zd„Zd ed„Z d„Z e d„ƒZ d„Z d „Zd „Zd „ZRS( sEclones a ClauseElement and applies an 'annotations' dictionary. Unlike regular clones, this clone also mimics __hash__() and __cmp__() of the original element so that it takes its place in hashed collections. A reference to the original element is maintained, for the important reason of keeping its hash value current. When GC'ed, the hash value may be reused, causing conflicts. .. note:: The rationale for Annotated producing a brand new class, rather than placing the functionality directly within ClauseElement, is **performance**. The __hash__() method is absent on plain ClauseElement which leads to significantly reduced function call overhead, as the use of sets and dictionaries against ClauseElement objects is prevalent, but most are not "annotated". cGsg|stj|ƒS|\}}yt|j}Wn#tk rUt|j|ƒ}nXtj|ƒSdS(N(tobjectt__new__tannotated_classest __class__tKeyErrort_new_annotation_type(tclstargstelementtvalues((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/annotation.pyR&s   cCs7|jjƒ|_||_||_t|ƒ|_dS(N(t__dict__tcopyt_Annotated__elementt _annotationsthasht_hash(tselfR R ((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/annotation.pyt__init__4s  cCs)|jjƒ}|j|ƒ|j|ƒS(N(RRtupdatet_with_annotations(RR t_values((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/annotation.pyt _annotate:s cCs4|jj|jƒ}|jjƒ|_||_|S(N(RRR RR(RR tclone((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/annotation.pyR?s cCsT|dkr|jS|jjƒ}x|D]}|j|dƒq)W|j|ƒSdS(N(tNoneRRRtpopR(RR RRtv((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/annotation.pyt _deannotateEs   cKs|jjj|||S(N(RRt_compiler_dispatch(Rtvisitortkw((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/annotation.pyRNscCs |jjS(N(Rt _constructor(R((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/annotation.pyR!QscCsL|jjƒ}||jkr"|S|jj|jƒ|j||jƒSdS(N(Rt_cloneR RRR(RR((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/annotation.pyR"Us cCs|j|j|jffS(N(RRR(R((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/annotation.pyt __reduce__`scCs|jS(N(R(R((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/annotation.pyt__hash__cscCsEt|jtjƒr+|jjj||ƒSt|ƒt|ƒkSdS(N(t isinstanceRRtColumnOperatorsRt__eq__R(Rtother((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/annotation.pyR'fsN(t__name__t __module__t__doc__RRRRRtTrueRRtpropertyR!R"R#R$R'(((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/annotation.pyRs       cs4‡‡‡fd†‰|dk r0ˆ|ƒ}n|S(sΉDeep copy the given ClauseElement, annotating each element with the given annotations dictionary. Elements within the exclude collection will be cloned but not annotated. csqˆr6t|dƒr6|jjˆƒr6|jƒ}n'ˆ|jkrW|jˆƒ}n|}|jdˆƒ|S(Nt proxy_setR(thasattrR.t intersectionR"RRt_copy_internals(telemtnewelem(t annotationsRtexclude(sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/annotation.pyR{sN(R(R R4R5((R4RR5sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/annotation.pyt_deep_annotatess cs@tjƒ‰‡‡‡fd†‰|dk r<ˆ|ƒ}n|S(s2Deep copy the given element, removing annotations.cs]ˆs|ˆkrQ|jdˆdtƒ}|jdˆƒˆsM|ˆ| s^