[Jc@s0ddkiZddklZlZddklZlZl Z ddk l Z l Z l Z lZlZddklZlZed4Zd5ZdefdYZdefdYZddZdZdefdYZdeifdYZdefdYZddZ!ei"Z#dei$fdYZ%de&e'd Z(de'd!Z)d"Z*e'd#Z+d$Z,d%Z-d&Z.d'Z/d(Z0d)Z1e'd*Z2e'd+Z3d,Z4d-Z5d.Z6d/Z7d0Z8d1Z9d2Z:d3Z;e;e_;e/e_/e+e_+dS(6iN(tsqltutil(t expressionRt operators(tMapperExtensiont EXT_CONTINUEtPropComparatortMapperPropertytAttributeExtension(t attributestexctdeletes delete-orphantalltmergetexpunges save-updatesrefresh-expiretnonetmappert instrumentortCascadeOptionscBs,eZdZddZdZdZRS(s5Keeps track of the options sent to relation().cascadetcCs-|p t}n td|idD}d|j|_d|jp d|j|_d|jp d|j|_d|jp d|j|_d|jp d|j|_d |jp d|j|_|io|i oti d nx2|D]*}|t jot i d |qqWdS( Ncssx|]}|iVqWdS(N(tstrip(t.0tc((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pys s t,s delete-orphanR R s save-updateR Rsrefresh-expiresWThe 'delete-orphan' cascade option requires 'delete'. This will raise an error in 0.6.sInvalid cascade option '%s'( tsettsplitt delete_orphanR t save_updateR Rtrefresh_expireRtwarnt all_cascadestsa_exct ArgumentError(tselftargtvaluestx((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyt__init__s  cCst||iddtS(Nt-t_(tgetattrtreplacetFalse(R!titem((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyt __contains__+sc Csadtdig}ddddddgD]*}t||ttjo ||q)q)~S( NsCascadeOptions(%s)RR RR RRsrefresh-expire(treprtjoinR(R*tTrue(R!t_[1]R$((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyt__repr__.s (t__name__t __module__t__doc__R%R,R1(((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyRs  t ValidatorcBs)eZdZdZdZdZRS(sRuns a validation method on an attribute value to be set or appended. The Validator class is used by the :func:`~sqlalchemy.orm.validates` decorator, and direct access is usually not needed. cCs||_||_dS(s Construct a new Validator. key - name of the attribute to be validated; will be passed as the second argument to the validation method (the first is the object instance itself). validator - an function or instance method which accepts three arguments; an instance (usually just 'self' for a method), the key name of the attribute, and the value. The function should return the same value given, unless it wishes to modify it. N(tkeyt validator(R!R6R7((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyR%=s cCs|i|i|i|S(N(R7tobjR6(R!tstatetvaluet initiator((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pytappendMscCs|i|i|i|S(N(R7R8R6(R!R9R:toldvalueR;((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyRPs(R2R3R4R%R<R(((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyR55s  tp_unionc st}hhx|iD]}||}t|tio|i}||||iD]3}|i|i|||i<|i |is cCs2g|_x"|pdD]}|i|qWdS(N((t _extensionsR<(R!t extensionstext((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyR%s cCs t|iS(N(RkRn(R!((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pytcopyscCs$|i||iid|dS(s<Insert a MapperExtension at the beginning of the collection.iN(t _registerRntinsert(R!t extension((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pytpushs cCs!|i||ii|dS(s6Append a MapperExtension at the end of the collection.N(RrRnR<(R!Rt((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyR<s cCs t|iS(s0Iterate over MapperExtensions in the collection.(titerRn(R!((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyt__iter__scCsgx`|ii|D]L}t||d}|o-|tt|j o|i|||(tidRR2(R!((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyR1^sN( R2R3R4RPR%RRRRRR1(((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyRs    cCsti|htd6|S(sDeep copy the given ClauseElement, annotating each element with the "_orm_adapt" flag. Elements within the exclude collection will be cloned but not annotated. t _orm_adapt(Rt_deep_annotateR/(telementtexclude((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyt _orm_annotatebst_ORMJoincBsMeZdZeiiZdeedZ deedZ dedZ RS(s/Extend Join to support ORM constructs as input.c Csd}t|do%|id}|o |i}qpn6t|\}}}|o|p| o |}nt|\} }} | o |} nd} |p| o || f|_t|to|i|} nXt|ti o$|p|i }n|i } n!t|t o |} nd} | ox| i d|d| dtdtd| \} }}}}}|o"ti||| |}|}n| }||_qntii|||||dS(Nt _orm_mappersitsource_selectabletdest_selectabletsource_polymorphictdest_polymorphictof_type(RPRRtrightRRJt basestringt get_propertyR Rt__clause_element__tpropertyRt _create_joinsR/RR.t_target_adapterRtJoinR%(R!tleftRtonclausetisoutert join_to_leftt adapt_fromt left_mappertleft_is_aliasedt right_mappertright_is_aliasedtadapt_toRtpjtsjtsourcetdestt secondaryttarget_adapter((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyR%qsH       cCst|||||S(N(R(R!RRRR((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyR.scCst|||t|S(N(RR/(R!RRR((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyt outerjoinsN( R2R3R4RRt__visit_name__RPR*R/R%R.R(((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyRls  1cCst|||||S(sProduce an inner join between left and right clauses. In addition to the interface provided by :func:`~sqlalchemy.sql.expression.join()`, left and right may be mapped classes or AliasedClass instances. The onclause may be a string name of a relation(), or a class-bound descriptor representing a relation. join_to_left indicates to attempt aliasing the ON clause, in whatever form it is passed, to the selectable passed as the left side. If False, the onclause is used as is. (R(RRRRR((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyR.scCst|||t|S(sUProduce a left outer join between left and right clauses. In addition to the interface provided by :func:`~sqlalchemy.sql.expression.outerjoin()`, left and right may be mapped classes or AliasedClass instances. The onclause may be a string name of a relation(), or a class-bound descriptor representing a relation. (RR/(RRRR((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyRs cCsnt|to%t|}|i|dt}n!t|tio |i}n|it i |dtS(stReturn criterion which selects instances with a given parent. instance a parent instance, which should be persistent or detached. property a class-attached descriptor, MapperProperty or string property name attached to the parent instance. \**kwargs all extra keyword arguments are propagated to the constructor of Query. tresolve_synonymstvalue_is_parent( RJRReRR/R RRtcompareRteq(R^RR((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyt with_parents   cCst|to|i|itfSt|oQt|tot||}n|o|i}n|}||i t fSd|t fSdS(slReturn mapping information given a class, mapper, or AliasedClass. Returns 3-tuple of: mapper, mapped selectable, boolean indicating if this is an aliased() construct. If the given entity is not a mapper, mapped class, or aliased construct, returns None, the entity, False. This is typically used to allow unmapped selectables through. N( RJRRRR/t_is_mapped_classRNRatcompileRR*RP(RRR((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyRs  cCs|t|tot||}||ifSt|to!ti||}||ifS|i|}||ifSdS(sReturn attribute/property information given an entity and string name. Returns a 2-tuple representing InstrumentedAttribute/MapperProperty. N(RJRR(RRNR tmanager_of_classt class_manager(RR6tdesc((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyt_entity_descriptors cCsVt|\}}}t|tio#g}|iD] }||q6~S|gSdS(N(RRJRt SelectableR(RRRRR0R((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyt _orm_columnss#cCst|\}}}|S(N(R(RRRR((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyt_orm_selectable scCs t|tS(N(RJR(R((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyt_is_aliased_classscCs |iiS(N(tmanagerR(R9((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyt _state_mapperscCsiy=ti|}|iipti|n|iiSWn%tij oti|nXdS(sGiven an object, return the primary Mapper associated with the object instance. Raises UnmappedInstanceError if no mapping is configured. N(R tinstance_stateRRR tUnmappedInstanceErrortNO_STATE(R^R9((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyRes cCsvy3ti|}|i}|djo tnWn%tij oti|nX|o|i}n|S(sGiven a class, return the primary Mapper associated with the key. Raises UnmappedClassError if no mapping is configured. N( R RRRPRR RtUnmappedClassErrorR(RiRRR((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyRa%s  cCsst|o|iSt|tot|d|St|do|o |iS|Snti|dS(NR( RRRJRNRaRRR R(tclass_or_mapperR((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyR:s  cCsti|}t|S(N(R Rt_state_has_identity(RR9((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyt has_identityGscCs t|iS(N(tboolR6(R9((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyRKscCs~ddkl}t|t|ifotSt|tiotSt|t o$t i |}|o t |i jStS(Ni(t mapperlib(tsqlalchemy.ormRRJRtMapperR/Rt ClauseElementR*RNR Rt _INSTRUMENTORtinfo(RRR((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyRNscCstti|S(s'Return a string describing an instance.(t state_strR R(R^((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyt instance_strYscCs6|djodSd|iit|ifSdS(s=Return a string describing an instance via its InstanceState.RPs <%s at 0x%x>N(RPRiR2RR8(R9((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyR^s cCst|d|S(Nt.(R(R^t attribute((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pyt attribute_strfscCst|d|S(NR(R(R9R((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pytstate_attribute_striscCs||jotS|djp |djotSy"ti|}ti|}Wntij otSX|idjp|idjotS|i|ijS(N(R/RPR*R RR RR6(tatbtstate_atstate_b((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pytidentity_equalls  (sdeletes delete-orphansallsmergesexpunges save-updatesrefresh-expireR(smapperR(<tsqlalchemy.exceptionst exceptionsRt sqlalchemyRRtsqlalchemy.sqlRRRtsqlalchemy.orm.interfacesRRRRRRR R t frozensetRRRRR5R[RjtdictRkRRRRPRt_deep_deannotatet_orm_deannotateRRR*R/R.RRRRRRRRReRaRRRRRRRRR (((s7/usr/lib/python2.6/site-packages/sqlalchemy/orm/util.pytsR( ! * 8HO  <