ÿØÿà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@@sdZddlmZddlmZddlmZddlZddlZddl Z ddl m Z ddl m Z dd l mZdd l mZdd l mZdd l mZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddl m Z ddl m Z!ddl m"Z"ddl m#Z#ddl m$Z$ddl m%Z%dd l mZddl%m&Z&ddl%m'Z'dd l%mZ(ddl%m)Z)e j*Z+e,a-ej.Z/ej0d Z1ej2j3Z4e"j5e#j6d!efd"YZ7d#Z8d$Z9d%Z:d&Z;d'Z<d(Z=d)e>fd*YZ?dS(+s5Logic to map Python classes to and from selectables. Defines the :class:`~sqlalchemy.orm.mapper.Mapper` class, the central configurational unit which associates a class with a database table. This is a semi-private module; the main configurational API of the ORM is available in :class:`~sqlalchemy.orm.`. i(tabsolute_import(tdeque(tchainNi(t attributes(texc(tinstrumentation(tloading(t properties(tutil(t_class_to_mapper(t _INSTRUMENTOR(t _state_mapper(t class_mapper(t state_str(t_MappedAttribute(tEXT_SKIP(tInspectionAttr(tMapperProperty(t PathRegistryi(tevent(t inspection(tlog(tschema(tsql(t expression(t operators(tvisitorst NO_ATTRIBUTEtMappercB@seZdZeZeZejdddfdddfddd feeeeeeeeeeeeeeeeeee e eeee ee eed d Z e Z eZ e d Ze d ZeZeZeZeZeZeZeZeZeZeZeZeZeZeZeZeZeZ eZ!e ej"dddZ#ej$dZ%dZ&dZ'dZ(dZ)dZ*dZ+dZ,dZ-e.dZ/dZ0dZ1dZ2edZ3eZ4e5dZ6e5dZ7e5d Z8d!Z9e e d"Z:d#Z;d$Z<d%Z=d&Z>d'Z?e d(Z@d)ZAd*ZBd+ZCd,ZDd-ZEd.ZFe d/ZGd0ZHe d1ZId2ZJd3ZKe5d4ZLe5d5ZMe5d6ZNeMZOe5d7ZPe5d8ZQe5d9ZRe5d:ZSe5d;ZTe5d<ZUe5d=ZVe5d>ZWe d?ZXeeed@ZYe5dAZZedBZ[e5dCZ\e5dDZ]e5dEZ^e5dFZ_e5dGZ`e5dHZadIZbe5dJZce5dKZddLZedMZfdNZgdOZhdPZidQZje5dRZkdSZldTZme dUZnedVZoeedWZpedXZqdYZresjtdZZud[Zve5d\Zwe5d]Zxe5d^Zye5d_Zzesjtd`Z{daZ|dbZ}dcZ~esjtddZdeZdfZdgZejdhdidjZe5dkZedlZe5dmZe5dnZdoZej$dpZRS(qsDefine the correlation of class attributes to database table columns. The :class:`.Mapper` object is instantiated using the :func:`~sqlalchemy.orm.mapper` function. For information about instantiating new :class:`.Mapper` objects, see that function's documentation. When :func:`.mapper` is used explicitly to link a user defined class with table metadata, this is referred to as *classical mapping*. Modern SQLAlchemy usage tends to favor the :mod:`sqlalchemy.ext.declarative` extension for class configuration, which makes usage of :func:`.mapper` behind the scenes. Given a particular class known to be mapped by the ORM, the :class:`.Mapper` which maintains it can be acquired using the :func:`.inspect` function:: from sqlalchemy import inspect mapper = inspect(MyClass) A class which was mapped by the :mod:`sqlalchemy.ext.declarative` extension will also have its mapper available via the ``__mapper__`` attribute. t extensions0.7s:class:`.MapperExtension` is deprecated in favor of the :class:`.MapperEvents` listener interface. The :paramref:`.mapper.extension` parameter will be removed in a future release.torder_bys1.1sThe :paramref:`.mapper.order_by` parameter is deprecated, and will be removed in a future release. Use :meth:`.Query.order_by` to determine the ordering of a result set.t non_primarys1.3sThe :paramref:`.mapper.non_primary` parameter is deprecated, and will be removed in a future release. The functionality of non primary mappers is now better suited using the :class:`.AliasedClass` construct, which can also be used as the target of a :func:`.relationship` in 1.3.idcC@s_tj|td|_t|_tj||_||_| t k r]tj| |_ n | |_ | |_ t | t r| |_t|_n | |_| t krt |_n$| tkrd|_n | |_||_t |_||_||_||_||_|pi|_g|_||_||_||_tj||_g|_tj |_!||_"||_#||_$t|_%t |_&t|_'i|_(||_)t|_*tj| pg|_+||_,|jo|j rt |_-n ||_-t |jtj.r,t/j0dn|j1|||_2||_3|tkrci|_4n ||_4|tk rtj5||_6n t|_6|rtj5||_7n t|_7t |_8t9j:z|j;j<j=|||j>|j?|j@|jA|jB|jC|jDtEtF_G|jHd|jIWdt9jJXdS(sNReturn a new :class:`~.Mapper` object. This function is typically used behind the scenes via the Declarative extension. When using Declarative, many of the usual :func:`.mapper` arguments are handled by the Declarative extension itself, including ``class_``, ``local_table``, ``properties``, and ``inherits``. Other options are passed to :func:`.mapper` using the ``__mapper_args__`` class variable:: class MyClass(Base): __tablename__ = 'my_table' id = Column(Integer, primary_key=True) type = Column(String(50)) alt = Column("some_alt", Integer) __mapper_args__ = { 'polymorphic_on' : type } Explicit use of :func:`.mapper` is often referred to as *classical mapping*. The above declarative example is equivalent in classical form to:: my_table = Table("my_table", metadata, Column('id', Integer, primary_key=True), Column('type', String(50)), Column("some_alt", Integer) ) class MyClass(object): pass mapper(MyClass, my_table, polymorphic_on=my_table.c.type, properties={ 'alt':my_table.c.some_alt }) .. seealso:: :ref:`classical_mapping` - discussion of direct usage of :func:`.mapper` :param class\_: The class to be mapped. When using Declarative, this argument is automatically passed as the declared class itself. :param local_table: The :class:`.Table` or other selectable to which the class is mapped. May be ``None`` if this mapper inherits from another mapper using single-table inheritance. When using Declarative, this argument is automatically passed by the extension, based on what is configured via the ``__table__`` argument or via the :class:`.Table` produced as a result of the ``__tablename__`` and :class:`.Column` arguments present. :param always_refresh: If True, all query operations for this mapped class will overwrite all data within object instances that already exist within the session, erasing any in-memory changes with whatever information was loaded from the database. Usage of this flag is highly discouraged; as an alternative, see the method :meth:`.Query.populate_existing`. :param allow_partial_pks: Defaults to True. Indicates that a composite primary key with some NULL values should be considered as possibly existing within the database. This affects whether a mapper will assign an incoming row to an existing identity, as well as if :meth:`.Session.merge` will check the database first for a particular primary key value. A "partial primary key" can occur if one has mapped to an OUTER JOIN, for example. :param batch: Defaults to ``True``, indicating that save operations of multiple entities can be batched together for efficiency. Setting to False indicates that an instance will be fully saved before saving the next instance. This is used in the extremely rare case that a :class:`.MapperEvents` listener requires being called in between individual row persistence operations. :param column_prefix: A string which will be prepended to the mapped attribute name when :class:`.Column` objects are automatically assigned as attributes to the mapped class. Does not affect explicitly specified column-based properties. See the section :ref:`column_prefix` for an example. :param concrete: If True, indicates this mapper should use concrete table inheritance with its parent mapper. See the section :ref:`concrete_inheritance` for an example. :param confirm_deleted_rows: defaults to True; when a DELETE occurs of one more rows based on specific primary keys, a warning is emitted when the number of rows matched does not equal the number of rows expected. This parameter may be set to False to handle the case where database ON DELETE CASCADE rules may be deleting some of those rows automatically. The warning may be changed to an exception in a future release. .. versionadded:: 0.9.4 - added :paramref:`.mapper.confirm_deleted_rows` as well as conditional matched row checking on delete. :param eager_defaults: if True, the ORM will immediately fetch the value of server-generated default values after an INSERT or UPDATE, rather than leaving them as expired to be fetched on next access. This can be used for event schemes where the server-generated values are needed immediately before the flush completes. By default, this scheme will emit an individual ``SELECT`` statement per row inserted or updated, which note can add significant performance overhead. However, if the target database supports :term:`RETURNING`, the default values will be returned inline with the INSERT or UPDATE statement, which can greatly enhance performance for an application that needs frequent access to just-generated server defaults. .. seealso:: :ref:`orm_server_defaults` .. versionchanged:: 0.9.0 The ``eager_defaults`` option can now make use of :term:`RETURNING` for backends which support it. :param exclude_properties: A list or set of string column names to be excluded from mapping. See :ref:`include_exclude_cols` for an example. :param extension: A :class:`.MapperExtension` instance or list of :class:`.MapperExtension` instances which will be applied to all operations by this :class:`.Mapper`. :param include_properties: An inclusive list or set of string column names to map. See :ref:`include_exclude_cols` for an example. :param inherits: A mapped class or the corresponding :class:`.Mapper` of one indicating a superclass to which this :class:`.Mapper` should *inherit* from. The mapped class here must be a subclass of the other mapper's class. When using Declarative, this argument is passed automatically as a result of the natural class hierarchy of the declared classes. .. seealso:: :ref:`inheritance_toplevel` :param inherit_condition: For joined table inheritance, a SQL expression which will define how the two tables are joined; defaults to a natural join between the two tables. :param inherit_foreign_keys: When ``inherit_condition`` is used and the columns present are missing a :class:`.ForeignKey` configuration, this parameter can be used to specify which columns are "foreign". In most cases can be left as ``None``. :param legacy_is_orphan: Boolean, defaults to ``False``. When ``True``, specifies that "legacy" orphan consideration is to be applied to objects mapped by this mapper, which means that a pending (that is, not persistent) object is auto-expunged from an owning :class:`.Session` only when it is de-associated from *all* parents that specify a ``delete-orphan`` cascade towards this mapper. The new default behavior is that the object is auto-expunged when it is de-associated with *any* of its parents that specify ``delete-orphan`` cascade. This behavior is more consistent with that of a persistent object, and allows behavior to be consistent in more scenarios independently of whether or not an orphanable object has been flushed yet or not. See the change note and example at :ref:`legacy_is_orphan_addition` for more detail on this change. :param non_primary: Specify that this :class:`.Mapper` is in addition to the "primary" mapper, that is, the one used for persistence. The :class:`.Mapper` created here may be used for ad-hoc mapping of the class to an alternate selectable, for loading only. :paramref:`.Mapper.non_primary` is not an often used option, but is useful in some specific :func:`.relationship` cases. .. seealso:: :ref:`relationship_non_primary_mapper` :param order_by: A single :class:`.Column` or list of :class:`.Column` objects for which selection operations should use as the default ordering for entities. By default mappers have no pre-defined ordering. :param passive_deletes: Indicates DELETE behavior of foreign key columns when a joined-table inheritance entity is being deleted. Defaults to ``False`` for a base mapper; for an inheriting mapper, defaults to ``False`` unless the value is set to ``True`` on the superclass mapper. When ``True``, it is assumed that ON DELETE CASCADE is configured on the foreign key relationships that link this mapper's table to its superclass table, so that when the unit of work attempts to delete the entity, it need only emit a DELETE statement for the superclass table, and not this table. When ``False``, a DELETE statement is emitted for this mapper's table individually. If the primary key attributes local to this table are unloaded, then a SELECT must be emitted in order to validate these attributes; note that the primary key columns of a joined-table subclass are not part of the "primary key" of the object as a whole. Note that a value of ``True`` is **always** forced onto the subclass mappers; that is, it's not possible for a superclass to specify passive_deletes without this taking effect for all subclass mappers. .. versionadded:: 1.1 .. seealso:: :ref:`passive_deletes` - description of similar feature as used with :func:`.relationship` :paramref:`.mapper.passive_updates` - supporting ON UPDATE CASCADE for joined-table inheritance mappers :param passive_updates: Indicates UPDATE behavior of foreign key columns when a primary key column changes on a joined-table inheritance mapping. Defaults to ``True``. When True, it is assumed that ON UPDATE CASCADE is configured on the foreign key in the database, and that the database will handle propagation of an UPDATE from a source column to dependent columns on joined-table rows. When False, it is assumed that the database does not enforce referential integrity and will not be issuing its own CASCADE operation for an update. The unit of work process will emit an UPDATE statement for the dependent columns during a primary key change. .. seealso:: :ref:`passive_updates` - description of a similar feature as used with :func:`.relationship` :paramref:`.mapper.passive_deletes` - supporting ON DELETE CASCADE for joined-table inheritance mappers :param polymorphic_load: Specifies "polymorphic loading" behavior for a subclass in an inheritance hierarchy (joined and single table inheritance only). Valid values are: * "'inline'" - specifies this class should be part of the "with_polymorphic" mappers, e.g. its columns will be included in a SELECT query against the base. * "'selectin'" - specifies that when instances of this class are loaded, an additional SELECT will be emitted to retrieve the columns specific to this subclass. The SELECT uses IN to fetch multiple subclasses at once. .. versionadded:: 1.2 .. seealso:: :ref:`with_polymorphic_mapper_config` :ref:`polymorphic_selectin` :param polymorphic_on: Specifies the column, attribute, or SQL expression used to determine the target class for an incoming row, when inheriting classes are present. This value is commonly a :class:`.Column` object that's present in the mapped :class:`.Table`:: class Employee(Base): __tablename__ = 'employee' id = Column(Integer, primary_key=True) discriminator = Column(String(50)) __mapper_args__ = { "polymorphic_on":discriminator, "polymorphic_identity":"employee" } It may also be specified as a SQL expression, as in this example where we use the :func:`.case` construct to provide a conditional approach:: class Employee(Base): __tablename__ = 'employee' id = Column(Integer, primary_key=True) discriminator = Column(String(50)) __mapper_args__ = { "polymorphic_on":case([ (discriminator == "EN", "engineer"), (discriminator == "MA", "manager"), ], else_="employee"), "polymorphic_identity":"employee" } It may also refer to any attribute configured with :func:`.column_property`, or to the string name of one:: class Employee(Base): __tablename__ = 'employee' id = Column(Integer, primary_key=True) discriminator = Column(String(50)) employee_type = column_property( case([ (discriminator == "EN", "engineer"), (discriminator == "MA", "manager"), ], else_="employee") ) __mapper_args__ = { "polymorphic_on":employee_type, "polymorphic_identity":"employee" } When setting ``polymorphic_on`` to reference an attribute or expression that's not present in the locally mapped :class:`.Table`, yet the value of the discriminator should be persisted to the database, the value of the discriminator is not automatically set on new instances; this must be handled by the user, either through manual means or via event listeners. A typical approach to establishing such a listener looks like:: from sqlalchemy import event from sqlalchemy.orm import object_mapper @event.listens_for(Employee, "init", propagate=True) def set_identity(instance, *arg, **kw): mapper = object_mapper(instance) instance.discriminator = mapper.polymorphic_identity Where above, we assign the value of ``polymorphic_identity`` for the mapped class to the ``discriminator`` attribute, thus persisting the value to the ``discriminator`` column in the database. .. warning:: Currently, **only one discriminator column may be set**, typically on the base-most class in the hierarchy. "Cascading" polymorphic columns are not yet supported. .. seealso:: :ref:`inheritance_toplevel` :param polymorphic_identity: Specifies the value which identifies this particular class as returned by the column expression referred to by the ``polymorphic_on`` setting. As rows are received, the value corresponding to the ``polymorphic_on`` column expression is compared to this value, indicating which subclass should be used for the newly reconstructed object. :param properties: A dictionary mapping the string names of object attributes to :class:`.MapperProperty` instances, which define the persistence behavior of that attribute. Note that :class:`.Column` objects present in the mapped :class:`.Table` are automatically placed into ``ColumnProperty`` instances upon mapping, unless overridden. When using Declarative, this argument is passed automatically, based on all those :class:`.MapperProperty` instances declared in the declared class body. :param primary_key: A list of :class:`.Column` objects which define the primary key to be used against this mapper's selectable unit. This is normally simply the primary key of the ``local_table``, but can be overridden here. :param version_id_col: A :class:`.Column` that will be used to keep a running version id of rows in the table. This is used to detect concurrent updates or the presence of stale data in a flush. The methodology is to detect if an UPDATE statement does not match the last known version id, a :class:`~sqlalchemy.orm.exc.StaleDataError` exception is thrown. By default, the column must be of :class:`.Integer` type, unless ``version_id_generator`` specifies an alternative version generator. .. seealso:: :ref:`mapper_version_counter` - discussion of version counting and rationale. :param version_id_generator: Define how new version ids should be generated. Defaults to ``None``, which indicates that a simple integer counting scheme be employed. To provide a custom versioning scheme, provide a callable function of the form:: def generate_version(version): return next_version Alternatively, server-side versioning functions such as triggers, or programmatic versioning schemes outside of the version id generator may be used, by specifying the value ``False``. Please see :ref:`server_side_version_counter` for a discussion of important points when using this option. .. versionadded:: 0.9.0 ``version_id_generator`` supports server-side version number generation. .. seealso:: :ref:`custom_version_counter` :ref:`server_side_version_counter` :param with_polymorphic: A tuple in the form ``(, )`` indicating the default style of "polymorphic" loading, that is, which tables are queried at once. is any single or list of mappers and/or classes indicating the inherited classes that should be loaded at once. The special value ``'*'`` may be used to indicate all descending classes should be loaded immediately. The second tuple argument indicates a selectable that will be used to query for multiple classes. .. seealso:: :ref:`with_polymorphic` - discussion of polymorphic querying techniques. tclass_cS@s|p ddS(Nii((tx((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pytxtsWhen mapping against a select() construct, map against an alias() of the construct instead.This because several databases don't allow a SELECT from a subquery that does not have an alias.t constructedN(KRtassert_arg_typettypeR tNonet class_managertto_listt_primary_key_argumentRtFalseRtalways_refresht isinstanceRtversion_id_proptversion_id_coltversion_id_generatortconcretetsingletinheritst local_tabletinherit_conditiontinherit_foreign_keyst_init_propertiest_delete_orphanstbatchteager_defaultst column_prefixRt_clause_element_as_exprtpolymorphic_ont_dependency_processorst immutabledictt validatorstpassive_updatestpassive_deletestlegacy_is_orphant_clause_adaptert_requires_row_aliasingt_inherits_equated_pairst_memoized_valuest_compiled_cache_sizet_reconstructort_deprecated_extensionstallow_partial_pkstconfirm_deleted_rowst SelectBasetsa_exctInvalidRequestErrort_set_with_polymorphictpolymorphic_loadtpolymorphic_identitytpolymorphic_maptto_settinclude_propertiestexclude_propertiest configuredt_CONFIGURE_MUTEXtacquiretdispatcht_eventst_new_mapper_instancet_configure_inheritancet"_configure_legacy_instrument_classt _configure_class_instrumentationt_configure_listenerst_configure_propertiest_configure_polymorphic_settert_configure_pkstTrueRt _new_mapperst_logt_expire_memoizationstrelease(tselfR R4Rt primary_keyRR3R5R6RRR,R/R0R=t_polymorphic_mapRRR1twith_polymorphicRQRKR9R;RURVRARBRLR:RCRH((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt__init__ks                                                         cC@s|S(s<Part of the inspection API. Returns self. ((Ri((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pytmapperscC@s|jS(sDPart of the inspection API. Returns self.class\_. (R (Ri((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pytentityssUse .persist_selectablecC@s|jS(N(tpersist_selectable(Ri((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt mapped_tablescC@s tj|S(N(Rt per_mapper(Ri((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt_path_registryscC@stj|_|jrTt|jtrEt|jdt|_nt|j |jj st j d|j j |jj j fn|j |jj kr|j rdpd}t j d||j j |fn|jdkr|jj|_|jj|_t|_n|j|jjk r|jrp|j|_x|jD]!}|jdk rHt|_qHqHWq|jdkrtj|jj|j|_ntj|jj|j|j|_tj|j}tj|jjd||_ n |j|_|j!dk r.|j r.|jj"|_"n |j |_"|j#dkrj|jj#|_#|jj$|_$nP|jj#dk r|j#|jj#k rtj%d|j#j&|jj#j&fn|j'tkr|j r|jj'tk r|jj'|_'n|jj(|_(|jj)|_)|jjj*||jj+|_+|jj,|_,|jj-pX|j-|_-|jj.|_.|j!dk r|j!|j(krtj%d|j!|j(|j!||j!fn||j(|j!|jddkri|j|jd|f|jdfndS(NiRi(R RlR'RP(RiRntsubcl((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyRs  cC@s_|jst|j stt|ts4t||_|jjj|j|jj|_x/|jD]!}|jdk rot |_ qoqoW|jj |_ x |j D]}|jj|_qW|jjj||jj|_|jj|_xa|jjD]P\}}||jkr|j||dtdd r|j||tqqWdS(sSet the given :class:`.Mapper` as the 'inherits' for this :class:`.Mapper`, assuming this :class:`.Mapper` is concrete and does not already have an inherits.tlocaltcolumnN(R1tAssertionErrorR3R-RRStupdateR~R=R'RdRER9tself_and_descendantsRRzRRARt_propstitemst_should_excludeR+t_adapt_inherited_property(RiRntmptkeytprop((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt_set_concrete_bases& cC@s||_|jtdS(N(R=RbRd(RiR=((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt_set_polymorphic_ons cC@s|jrS|jj|jjttg|jjD]}|j^q5}n t}x0|jD]%}||krf|j||qfqfWdS(N(R3RZt_updateRRR~RJt_adapt_instrument_class(Ritmtsuper_extensionstext((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyR^s +  cC@s}|jr=ttg|jjD]}|j^q}n t}x0|jD]%}||krP|j||qPqPWdS(N(R3RRR~RJt_adapt_listener(RiRRR((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyR`s +  cC@stj|j}|jrk| s,|j rEtjd|jn||_|jj |_ t t |UsisJMapper %s could not assemble any primary key columns for mapped table '%s'slCould not assemble any primary keys for locally mapped table '%s' - no rows will be persisted in this Table.tignore_nonexistent_tabless"Identified primary key columns: %sc3@sT|]J}j|jkrt|d sA|jjkrj|VqdS(ttableN(t_columntopropertyt_identity_key_propsRRt_cols_by_table(Rtcol(Ri(sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pys s((Rt find_tablesRpttablest _pks_by_tableRRt column_setRRt proxy_setRRRRjt issupersettordered_column_sett intersectionRR*Rt OrderedSettaddtlenRNR|RR4R-RtTableRR3R1treduce_columnstcorresponding_columnRdRRft_readonly_props( RiRtall_colstpk_colsRtttkRRj((RisH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyRcKsf  (       %   cC@stj|_|_tj|_t||_|jrsx3|jj D]\}}|j ||t qMWn|j rxg|j jj D]P\}}||jkr|j ||dt dd r|j||t qqWnx|jjD]}||jkrqn|jpd|j}|j |j|d|jjj|d|rZqnx6|jD](}||jkrg|j|j}qgqgW|j ||dt dtqWdS(NRRR#Rt setparent(RtOrderedPropertiestcolumnsRt OrderedDictRt_ColumnMappingRR7Rt_configure_propertyR+R3RR'RRpR;RR4tcontains_columnR~Rd(RiRRRt column_keyRn((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyRas4   c @s1t}|jd k rUt}t|jtjrty|j|j|_Wqttk rpt j d|jqtXn|j|j kr|j |j}nt|jt rt|jt jst j dn|j}n[tj|jst j dn7|jj|j}|d krt}t}|j}t|tjr|jd ksu|jdj|d krt jd|jqnt}t|dd }|r|j|j|jt|rt jd|jqn|jd|_}|j}t j|d|}|j||d |d t|jd |_|jnx|jD]}|jd k rb|j|jkr|j|_n|jj|j|_|jd k r|j|_|j |_ n d |_d SqbW|r$fd }fd} ||_| |_ n d |_d S(sConfigure an attribute on the mapper representing the 'polymorphic_on' column, if applicable, and not already generated by _configure_properties (which is typical). Also create a setter function which will assign this attribute to the value of the 'polymorphic_identity' upon instance construction, also if applicable. This routine will run when an instance is created. sPCan't determine polymorphic_on value '%s' - no attribute is mapped to this name.sUOnly direct column-mapped property or SQL expression can be passed for polymorphic_oniskCould not map polymorphic_on column '%s' to the mapped table - polymorphic loads will not function properlyRs6Cannot exclude or override the discriminator column %rt_sa_polymorphic_ont _instrumentRRiNc@s5|j}|jj|||jjjddS(N(tdicttget_implRRRnRRR'(tstatetdict_(tpolymorphic_key(sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt_set_polymorphic_identityvs   c@sF|krB||jkrBtjdt||fndS(NsnFlushing object %s with incompatible polymorphic identity %r; the object may not refresh and/or load correctly(t"_acceptable_polymorphic_identitiesRt warn_limitedR (RnRR(R(sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt_validate_polymorphic_identitys   (!R+R=R'RdR-RRRtKeyErrorRNR|RRRtColumnPropertyRt _is_columnRpRRtColumnRlRORtgetattrRRtlabelRRR~RR( RiRtsetterRRt instrumentRRnRR((RsH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyRbs                  cC@s%|jdk r|j|jSdSdS(N(R/R'R(Ri((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt_version_id_propscC@sjt}t|g}xK|re|j}|j|jkr|j|j|j|jqqW|S(N(RRtpopleftRpRRRtextendRz(Rit identitieststacktitem((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyRs   cC@st|jjS(N(t frozensetRtvalues(Ri((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt _prop_setscC@s|js(|j||dtdtn|||jkr|jj||}||ks|t|tjr|j |j kr|j|t j d|dt qndS(NRR(R1RR+RR(t_get_class_attr_mroR-RtInstrumentedAttributet _parententitytparentRtConcreteInheritedPropertyRd(RiRRRtimplementing_attribute((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyRs     c C@s|jd||jjt|ts=|j||}nt|tjrG|jj |j d}|dkr|j r|g}x|j j D]s}|jj |j d}|dk rx|D]}|jjqW|jj |j d}Pn|j|qWn|dkrp|j d}t|drt|d sZ|j|jkr|jj|qnQt|dr|j|jkr||j|jkr|j|jj|nt|ds||jkp|j d|jk|_n||j |(tidR R}(Ri((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt__repr__scC@sGd|jj|jrdpd|jdk r9|jjn |jjfS(Nsmapped class %s%s->%ss (non-primary)R#(R R}RR4R'RRp(Ri((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt__str__s  cC@st}x|jD]r}xi|jD]^\}}t}tj|j||d|j}|jrl|rltS|j r#| r#tSq#WqW|jr|StSdS(Nt optimistic( R+R~R8RdRRt has_parentt has_identityRC(RiRtorphan_possibleRnRRR@((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt _is_orphans  cC@s ||jkS(N(R(RiR((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt has_propertyscC@sY|rtjrtny|j|SWn*tk rTtjd||fnXdS(s?return a MapperProperty associated with the given key. s Mapper '%s' has no property '%s'N(RReRRRRNRO(RiRt_configure_mappers((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt get_propertys  cC@s |j|S(sdGiven a :class:`.Column` object, return the :class:`.MapperProperty` which maps this column.(R(RiR((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pytget_property_by_columnscC@s&tjrtnt|jjS(s1return an iterator of all MapperProperty objects.(RReRtiterRR (Ri((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pytiterate_propertiess  cC@s4|dkrt|j}n|rt}x}tj|D]l}t|}|j|sztjd||fn|dkr|j |j q=|j |q=Wg|jD]}||kr|^q}ng}|dk r0tt j|dt}g|D]}|j|kr |^q }n|S(sgiven a with_polymorphic() argument, return the set of mappers it represents. Trims the list of mappers to just those represented within the given selectable, if present. This helps some more legacy-ish mappings. Rs%r does not inherit from %rtinclude_aliasesN(RRRRR)R tisaRNROR'RR~RRRRdR4(Ritspect selectabletmappersRR((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt_mappers_from_specs&    + +cC@s|j}x|D]x}||kr(qn|jrCtjdq|js|rm|j|j|j}q|j|j|j}qqW|S(sgiven a list of mappers (assumed to be within this mapper's inheritance hierarchy), construct an outerjoin amongst those mapper's mapped tables. s^'with_polymorphic()' requires 'selectable' argument when concrete-inheriting mappers are used.( RpR1RNROR2RR4R5t outerjoin(RiRNt innerjointfrom_objR((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt_selectable_from_mappers0s      cC@sV|jrN|jrN|jdk rN|jji|d6jd|jDSdSdS(Nt parentmappercs@s|]}|jVqdS(N(RR(RR((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pys Os(R2R3R=R't _annotatetin_R(Ri((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt_single_table_criterionKs!cC@s0tjrtn|js gS|j|jS(N(RReRRlRO(Ri((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt_with_polymorphic_mappersTs    cC@sO|js|jS|j\}}|dk r/|S|j|j||tSdS(N(RlRpR'RSROR+(RiRLRM((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt_with_polymorphic_selectable\s  cC@std|jjDS(Ncs@s1|]'\}}|td|DfVqdS(cs@s!|]}|jjr|VqdS(N(R&tshould_evaluate_none(RR((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pys usN(R (RRR((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pys rs(RRR(Ri((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt_insert_cols_evaluating_noneoscC@std|jjDS(Ncs@s1|]'\}}|td|DfVqdS(cs@sC|]9}|j r|j r|j r|jj r|jVqdS(N(Rjtserver_defaulttdefaultR&RZR(RR((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pys s    N(R (RRR((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pys ~s (RRR(Ri((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt_insert_cols_as_none{s c@s#tfdjjDS(Nc3@s7|]-\}}|tfd|DfVqdS(c3@s%|]}j|j|fVqdS(N(RR(RR(Ri(sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pys sN(R(RRR(Ri(sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pys s(RRR(Ri((RisH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt_propkey_to_cols cC@std|jjDS(Ncs@s=|]3\}}|tg|D]}|j^qfVqdS(N(R R(RRtpksR((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pys s(RRR(Ri((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt_pk_keys_by_tablesc@s#tfdjjDS(Nc3@sD|]:\}}|tg|D]}j|j^qfVqdS(N(R RR(RRR`R(Ri(sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pys s(RRR(Ri((RisH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt_pk_attr_keys_by_tables cC@std|jjDS(Ncs@sL|]B\}}|tg|D]}|jdk r|j^qfVqdS(N(R R\R'R(RRRR((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pys s (RRR(Ri((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt_server_default_colss cC@st}xu|jjD]d\}}xU|D]M}|jdk sP|jdk r,||jkr,|j|j|jq,q,WqW|S(N( RRRR\R'tserver_onupdateRRR(RitresultRRR((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt&_server_default_plus_onupdate_propkeyss  "cC@std|jjDS(Ncs@sL|]B\}}|tg|D]}|jdk r|j^qfVqdS(N(R RdR'R(RRRR((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pys s (RRR(Ri((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt_server_onupdate_default_colss cC@s|jS(s$The :func:`.select` construct this :class:`.Mapper` selects from by default. Normally, this is equivalent to :attr:`.persist_selectable`, unless the ``with_polymorphic`` feature is in use, in which case the full "polymorphic" selectable is returned. (RY(Ri((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyRMs cC@s|jr>|s|jd}n|tkrS|jd}qSn|tkrSd}n|j||}|dk r{||fS||j||fSdS(Nii(RlR+R'RORS(RiRLRMRQRN((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt_with_polymorphic_argss      cC@st|j|jS(N(Rt_iterate_polymorphic_propertiesRX(Ri((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt_polymorphic_propertiesscc@s|dkr|j}n|s:x|jD] }|Vq(Wnxtjtg|g|D]}t|j^qTD]H}t|dtr|j dkss|j d|j k rqsn|VqsWdS(sUReturn an iterator of MapperProperty objects which will render into a SELECT.RiN( R'RXRIRt unique_listRRRR+R=R(RiRNRRn((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyRis    0cC@s#tjrtntj|jS(s]A namespace of all :class:`.MapperProperty` objects associated this mapper. This is an object that provides each property based on its key name. For instance, the mapper for a ``User`` class which has ``User.name`` attribute would provide ``mapper.attrs.name``, which would be the :class:`.ColumnProperty` representing the ``name`` column. The namespace object can also be iterated, which would yield each :class:`.MapperProperty`. :class:`.Mapper` has several pre-filtered views of this attribute which limit the types of properties returned, including :attr:`.synonyms`, :attr:`.column_attrs`, :attr:`.relationships`, and :attr:`.composites`. .. warning:: The :attr:`.Mapper.attrs` accessor namespace is an instance of :class:`.OrderedProperties`. This is a dictionary-like object which includes a small number of named methods such as :meth:`.OrderedProperties.items` and :meth:`.OrderedProperties.values`. When accessing attributes dynamically, favor using the dict-access scheme, e.g. ``mapper.attrs[somename]`` over ``getattr(mapper.attrs, somename)`` to avoid name collisions. .. seealso:: :attr:`.Mapper.all_orm_descriptors` (RReRRtImmutablePropertiesR(Ri((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pytattrs s"  cC@stjt|jjS(s+A namespace of all :class:`.InspectionAttr` attributes associated with the mapped class. These attributes are in all cases Python :term:`descriptors` associated with the mapped class or its superclasses. This namespace includes attributes that are mapped to the class as well as attributes declared by extension modules. It includes any Python descriptor type that inherits from :class:`.InspectionAttr`. This includes :class:`.QueryableAttribute`, as well as extension types such as :class:`.hybrid_property`, :class:`.hybrid_method` and :class:`.AssociationProxy`. To distinguish between mapped attributes and extension attributes, the attribute :attr:`.InspectionAttr.extension_type` will refer to a constant that distinguishes between different extension types. When dealing with a :class:`.QueryableAttribute`, the :attr:`.QueryableAttribute.property` attribute refers to the :class:`.MapperProperty` property, which is what you get when referring to the collection of mapped properties via :attr:`.Mapper.attrs`. .. warning:: The :attr:`.Mapper.all_orm_descriptors` accessor namespace is an instance of :class:`.OrderedProperties`. This is a dictionary-like object which includes a small number of named methods such as :meth:`.OrderedProperties.items` and :meth:`.OrderedProperties.values`. When accessing attributes dynamically, favor using the dict-access scheme, e.g. ``mapper.all_orm_descriptors[somename]`` over ``getattr(mapper.all_orm_descriptors, somename)`` to avoid name collisions. .. seealso:: :attr:`.Mapper.attrs` (RRlRR(t_all_sqla_attributes(Ri((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pytall_orm_descriptors= s+cC@s|jtjS(sReturn a namespace of all :class:`.SynonymProperty` properties maintained by this :class:`.Mapper`. .. seealso:: :attr:`.Mapper.attrs` - namespace of all :class:`.MapperProperty` objects. (t_filter_propertiesRtSynonymProperty(Ri((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pytsynonymsl s cC@s|jtjS(sReturn a namespace of all :class:`.ColumnProperty` properties maintained by this :class:`.Mapper`. .. seealso:: :attr:`.Mapper.attrs` - namespace of all :class:`.MapperProperty` objects. (RpRR(Ri((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt column_attrsy s cC@s|jtjS(s4A namespace of all :class:`.RelationshipProperty` properties maintained by this :class:`.Mapper`. .. warning:: the :attr:`.Mapper.relationships` accessor namespace is an instance of :class:`.OrderedProperties`. This is a dictionary-like object which includes a small number of named methods such as :meth:`.OrderedProperties.items` and :meth:`.OrderedProperties.values`. When accessing attributes dynamically, favor using the dict-access scheme, e.g. ``mapper.relationships[somename]`` over ``getattr(mapper.relationships, somename)`` to avoid name collisions. .. seealso:: :attr:`.Mapper.attrs` - namespace of all :class:`.MapperProperty` objects. (RpRtRelationshipProperty(Ri((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt relationships scC@s|jtjS(sReturn a namespace of all :class:`.CompositeProperty` properties maintained by this :class:`.Mapper`. .. seealso:: :attr:`.Mapper.attrs` - namespace of all :class:`.MapperProperty` objects. (RpRtCompositeProperty(Ri((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt composites s c@sBtjrtntjtjfd|jjDS(Nc3@s0|]&\}}t|r||fVqdS(N(R-(RRtv(ttype_(sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pys s(RReRRRlRRR(RiRy((RysH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyRp s   cC@sog|jD]$}|tjdd|jf^q }tjg|D]\}}||k^qAtj|fS(screate a "get clause" based on the primary key. this is used by query.get() and many-to-one lazyloads to load this item by primary key. RyN(RjRt bindparamR'R&tand_Rt column_dict(RiRjtparamsRRx((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt _get_clause s1+c@setjfd}xC|jjD]5}|jdk r(tj|jii|d6q(q(WS(sCreate a map of all equivalent columns, based on the determination of column pairs that are equated to one another based on inherit condition. This is designed to work with the queries that util.polymorphic_union comes up with, which often don't include the columns from the base table directly (including the subclass table columns only). The resulting structure is a dictionary of columns mapped to lists of equivalent columns, e.g.:: { tablea.col1: {tableb.col1, tablec.col1}, tablea.col2: {tabled.col2} } c@s|jtjkr|jkr;|jj|jntj|jf|j<|jkr|jj|jqtj|jf|jReturn True if the this mapper inherits from the given mapper.(R3tbool(RiRR((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyRK1 s cc@s%|}x|r |V|j}q WdS(N(R3(RiR((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyR~9 s cC@sXg}t|g}x3|rJ|j}|j||j|jqWtj|S(sThe collection including this mapper and all descendant mappers. This includes not just the immediately inheriting mappers but all their inheriting mappers as well. (RRRRRzRRy(Rit descendantsR R ((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyR? s   cC@s t|jS(sCIterate through the collection including this mapper and all descendant mappers. This includes not just the immediately inheriting mappers but all their inheriting mappers as well. To iterate through an entire hierarchy, use ``mapper.base_mapper.polymorphic_iterator()``. (RHR(Ri((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pytpolymorphic_iteratorO s cC@s |jjS(sSReturn the primary mapper corresponding to this mapper's class key (class).(R(Rn(Ri((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyR\ scC@s |jjjS(N(R(RnR(Ri((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pytprimary_base_mapperb scC@s^|j}|r2g|D]}|j|^q}nx%|D]}|j|s9tSq9WtSdS(N(RjRt_has_keyR+Rd(RiRetadapterRRR((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt_result_has_identity_keyf s # c@sX|j}|r2g|D]}|j|^q}n|jtfd|D|fS(sReturn an identity-map key for use in storing/retrieving an item from the identity map. :param row: A :class:`.RowProxy` instance. The columns which are mapped by this :class:`.Mapper` should be locatable in the row, preferably via the :class:`.Column` object directly (as is the case when a :func:`.select` construct is executed), or via string names of the form ``_``. c3@s|]}|VqdS(N((RR(trow(sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pys s(RjRRR(RiRtidentity_tokenRRR((RsH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pytidentity_key_from_rowp s #cC@s|jt||fS(sReturn an identity-map key for use in storing/retrieving an item from an identity map. :param primary_key: A list of values indicating the identifier. (RR(RiRjR((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pytidentity_key_from_primary_key scC@s"tj|}|j|tjS(sReturn the identity key for the given instance, based on its primary key attributes. If the instance's state is expired, calling this method will result in a database check to see if the object has been deleted. If the row no longer exists, :class:`~sqlalchemy.orm.exc.ObjectDeletedError` is raised. This value is typically also found on the instance state under the attribute name `key`. (Rtinstance_statet_identity_key_from_statet PASSIVE_OFF(RitinstanceR((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pytidentity_key_from_instance s cC@sZ|j}|j}|jtg|jD]%}||jjj|||^q%|jfS(N( RRRRRRtimplRR(RiRtpassiveRRR((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyR s  2cC@s,tj|}|j|tj}|dS(sGReturn the list of primary key values for the given instance. If the instance's state is expired, calling this method will result in a database check to see if the object has been deleted. If the row no longer exists, :class:`~sqlalchemy.orm.exc.ObjectDeletedError` is raised. i(RRRR(RiRRt identity_key((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pytprimary_key_from_instance s cC@s!g|jD]}|j|^q S(N(RjR(RiR((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyR scC@s5t}x%|jD]}|j|j|qW|S(N(RRRR(Rit collectionR((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt _all_pk_props s cC@s5t|j}|jdk r1|j|jn|S(N(RRjR=R'R(Ritcols((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt_should_undefer_in_wildcard scC@sd|jDS(NcS@sh|]}|jqS((R(RR((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pys s (R(Ri((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt_primary_key_propkeys scC@s0|j|}|j|jjj||d|S(NR(RRRRR(RiRRRRR((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt_get_state_attr_by_column s cC@s1|j|}|j|jjj|||dS(N(RRRRtset_committed_value(RiRRRR/R((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt#_set_committed_state_attr_by_column s cC@s4|j|}|j|jjj|||ddS(N(RRRRRR'(RiRRRR/R((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt_set_state_attr_by_column s cC@s:tj|}tj|}|j|||dtjS(NR(RRt instance_dictt#_get_committed_state_attr_by_columnR(RiRRRR((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt_get_committed_attr_by_column scC@s0|j|}|j|jjj||d|S(NR(RRRRtget_committed_value(RiRRRRR((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyR s c @sj}ttg|D]/}||jD]}tj|dt^q'qjjkrgdSdt fdYfd}g}yt }xt t jD]p} | jkrt}nt| jtjsdS|r| j r|jtj| jii|d6qqWWnk rFdSXtj|} g} x"|D]}| j||jqcWtj| | dtS(slassemble a WHERE clause which retrieves a given state by primary key, using a minimized set of tables. Applies to a joined-table inheritance mapper where the requested attribute names are only present on joined tables, not the base table. The WHERE clause attempts to include only those tables to minimize joins. t check_columnstColumnsNotAvailablecB@seZRS((R}t __module__(((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyR sc@s|j}|j}|dks*|dkr.dS|jkrjj|dtj}|tj krynt j d|d|jj |_no|jkr jj|dtj}|tj krnt j d|d|jj |_ndS(NRRy( RRR'RRRRtPASSIVE_NO_INITIALIZEtorm_utilt _none_setRRzR&(Rtleftcoltrightcoltleftvaltrightval(RRiRR(sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyR s0      Rt use_labelsN(RRRRRRRdRR4R't ExceptionR+treversedRR~R-Rt TableClauseR2RRtcloned_traverseR5RR{Rtselect( RiRtattribute_namestpropsRRRtallcondststartRntcondR((RRiRRsH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt_optimized_get_statement s@  5   cc@sm|j|ri|}xQ|jD]@}|V||k rL||jkrLPn|}||kr"Pq"q"WndS(N(RKR~RX(RiRntprevR((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt_iterate_to_target_viawpolyJ s cC@s|s<|}x|j|D]}|jdkr|SqWnt|}d|D}xh|j|gD]T}|j}xB|j|D]1}|jdks||kr|j||SqWqkWdS(NRxcS@si|]}||jqS((Rn(Rte((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pys a s (RRQRRRnRR'(Ritenabled_via_opttpolymorphic_fromRnRtenabled_via_opt_mappersRo((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt_should_selectin_loadW s    ssqlalchemy.ext.bakedssqlalchemy.orm.strategy_optionsc @sjstjj}t|gj}|j}|j}xkjD]`}|jks~||kr|j |j ft |j q]|j |j fit d6q]Wtjdkrtjjn jdjrGjkst|jjfdf} | jn$|jjfdf} | fd7} | ||fS(smAssemble a BakedQuery that can load the columns local to this subclass as a SELECT with IN. t do_nothingiic@s|jjjjS(N(tquerytselect_entity_fromRMt_adapt_all_clauses(tsession(Ro(sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyR" sc@s |jS(N(R(R(Ri(sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyR" R#c@s1|jjtjddtjjS(Nt primary_keyst expanding(tfilterRVRRzRdRRj(tq(tin_exprRi(sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyR" s!(R3RRR=RRtLoadRmRtset_generic_strategyRRt strategy_keyRdRRjRttuple_tis_aliased_classRnt BakedQueryt_compiled_cachetspoil( Ritbakedtstrategy_optionsRotpolymorphic_propt keep_propst disable_optt enable_optRR((RoRRisH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt_subclass_load_via_inm s6       cC@s |j|S(N(R(Ri((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt_subclass_load_via_in_mapper scc@stt}tt}}|jj|s4ttt|jjj|||jfg}x |ro|d\}} } } |s|j qgn| |kr |j } || j krqgnt| j || | ||} | rl|j | |ddfqlqg| |krg|j \}}}}||||fV|j t|jj|||fqgqgWdS(s.Iterate each element and its mapper in an object graph, for all relationships that meet the given cascade rule. :param type\_: The name of the cascade rule (i.e. ``"save-update"``, ``"delete"``, etc.). .. note:: the ``"all"`` cascade is not accepted here. For a generic object traversal function, see :ref:`faq_walk_objects`. :param state: The lead InstanceState. child items will be processed per the relationships defined for this object's mapper. :return: the method yields individual object instances. .. seealso:: :ref:`unitofwork_cascades` :ref:`faq_walk_objects` - illustrates a generic function to traverse all objects without relying on cascades. iN(RtobjectRnRKRRRR RRRtcascadetcascade_iteratorRR'(RiRyRthalt_ontvisited_statestprptmppt visitablestiteratort item_typet parent_statet parent_dictRtqueueRtinstance_mappertcorresponding_statetcorresponding_dict((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyR sD -      cC@stj|jS(N(RtLRUCacheRH(Ri((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyR sc @six8|jjD]*}x!|jD]}j||q#WqWg}xUjD]G\}}|j}|rT|jg|jD]}||f^qqTqTWfd}tjd|d|}t j } x|D]}|| |RCRDRFRGRIRORSRWRXRYtwith_polymorphic_mappersR[R^R_RaRbRcRfRgRMRhRjRiRmRoRrRsRuRwRpR~RRRRRRKR~RRRRRRRRRtPASSIVE_RETURN_NEVER_SETRRRRRRRRRRRRRRt dependenciesRRRRR R R(((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyREsF!    6             "     Y  e 3   o V           "        &/   * (            X : M3 cC@stjs dStjztr$dStazltjs:dSt}tjjtj x*t t D]}d}x<|jj D].}|||j}|tkr|t}Pq|q|W|tkrqcnt|dtrtjd||jf}|j|_|n|jscy.|j|j|jj||jWqtk r{tjd}t|dsu||_nqXqcqcW|stt_nWdtaXWdtjXtjjtjdS(sInitialize the inter-mapper relationships of all mappers that have been constructed thus far. This function can be called any number of times, but in most cases is invoked automatically, the first time mappings are used, as well as whenever mappings are used and additional not-yet-configured mappers have been constructed. Points at which this occur include when a mapped class is instantiated into an instance, as well as when the :meth:`.Session.query` method is used. The :func:`.configure_mappers` function provides several event hooks that can be used to augment its functionality. These methods include: * :meth:`.MapperEvents.before_configured` - called once before :func:`.configure_mappers` does any work; this can be used to establish additional options, properties, or related mappings before the operation proceeds. * :meth:`.MapperEvents.mapper_configured` - called as each individual :class:`.Mapper` is configured within the process; will include all mapper state except for backrefs set up by other mappers that are still to be configured. * :meth:`.MapperEvents.after_configured` - called once after :func:`.configure_mappers` is complete; at this stage, all :class:`.Mapper` objects that are known to SQLAlchemy will be fully configured. Note that the calling application may still have other mappings that haven't been produced yet, such as if they are in modules as yet unimported. NRsOne or more mappers failed to initialize - can't proceed with initialization of other mappers. Triggering mapper: '%s'. Original exception was: %si(RReRXRYt_already_compilingRdR+RZt _for_classtbefore_configuredRRR'tbefore_mapper_configuredR RRRNRORRWR,Rgtmapper_configuredRtsystexc_infoRRhtafter_configured(thas_skipRnt run_configuretfnRR((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyRL sV#               cC@s t|_|S(s-Decorate a method as the 'reconstructor' hook. Designates a method as the "reconstructor", an ``__init__``-like method that will be called by the ORM after the instance has been loaded from the database or otherwise reconstituted. The reconstructor will be invoked with no arguments. Scalar (non-collection) database-mapped attributes of the instance will be available for use within the function. Eagerly-loaded collections are generally not yet available and will usually only contain the first element. ORM state changes made to objects at this stage will not be recorded for the next flush() operation, so the activity within a reconstructor should be conservative. .. seealso:: :ref:`mapping_constructors` :meth:`.InstanceEvents.load` (RdR(R&((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt reconstructor s c@s=|jdt|jdtfd}|S(sDecorate a method as a 'validator' for one or more named properties. Designates a method as a validator, a method which receives the name of the attribute as well as a value to be assigned, or in the case of a collection, the value to be added to the collection. The function can then raise validation exceptions to halt the process from continuing (where Python's built-in ``ValueError`` and ``AssertionError`` exceptions are reasonable choices), or can modify or replace the value before proceeding. The function should otherwise return the given value. Note that a validator for a collection **cannot** issue a load of that collection within the validation routine - this usage raises an assertion to avoid recursion overflows. This is a reentrant condition which is not supported. :param \*names: list of attribute names to be validated. :param include_removes: if True, "remove" events will be sent as well - the validation function must accept an additional argument "is_remove" which will be a boolean. :param include_backrefs: defaults to ``True``; if ``False``, the validation function will not emit if the originator is an attribute event related via a backref. This can be used for bi-directional :func:`.validates` usage where only one validator should emit per attribute operation. .. versionadded:: 0.9.0 .. seealso:: :ref:`simple_validators` - usage examples for :func:`.validates` tinclude_removestinclude_backrefsc@s$|_id6d6|_|S(NR(R)(RR(R&(R)R(tnames(sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pytwrap s   (RR+Rd(R*tkwR+((R)R(R*sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt validates s#cC@s3|jjt}|jr/|j|jndS(N(RRR RIR(Rtctxtinstrumenting_mapper((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyR s cC@s2|jjt}|r.tjr.tq.ndS(sInitial mapper compilation trigger. instrumentation calls this one when InstanceState is first generated, and is needed for legacy mutable attributes to work. N(RRR RReR(RRR/((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyR s cC@sN|jjjt}|rJtjr.tn|jrJ|j|qJndS(sRun init_instance hooks. This also includes mapper compilation, normally not needed here but helps with some piecemeal configuration scenarios (such as in the ORM tutorial). N(RRRR RReRR(RR9tkwargsR/((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyR s    RcB@s&eZdZdZdZdZRS(s4Error reporting helper for mapper._columntoproperty.RncC@s ||_dS(N(Rn(RiRn((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyRm& scC@si|jjj|}|rItjd|jj|j|j|fntjd||jfdS(NsDColumn '%s.%s' is not available, due to conflicting property '%s':%rs*No column %s is configured on mapper %s...(RnRRtorm_exctUnmappedColumnErrorRRR(RiRR((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyt __missing__) s%(Rn(R}RRt __slots__RmR3(((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pyR! s (@Rt __future__Rt collectionsRt itertoolsRR!RtweakrefR#RRR1RRRRRtbaseR R R R R t interfacesRRRRt path_registryRRRNRRRRRRRRtWeakKeyDictionaryRR+Rt!group_expirable_memoized_propertyR1tsymbolRt threadingtRLockRXt_self_inspectst class_loggerRRR'R-RRRRR(((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.pytsx       e  1