/
opt
/
alt
/
python27
/
lib64
/
python2.7
/
site-packages
/
sqlalchemy
/
ext
/
declarative
/
up file
home
� 1��fc @ s d Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z e j d d � d � � Z d e f d � � YZ d e f d � � YZ d e f d � � YZ d S( s1 Public API functions and helpers for declarative.i ( t inspection( t util( t exc( t registry( t relationships( t _mapper_or_none( t _resolver( t _DeferredMapperConfig( t polymorphic_union( t Table( t OrderedDicts 2.0s� the instrument_declarative function is deprecated and will be removed in SQLAlhcemy 2.0. Please use :meth:`_orm.registry.map_declarativelyc C s t d | d | � j | � d S( s� Given a class, configure the class declaratively, using the given registry, which can be any dictionary, and MetaData object. t metadatat class_registryN( R t map_declaratively( t clst cls_registryR ( ( sX /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/declarative/extensions.pyt instrument_declarative s t ConcreteBasec B s, e Z d Z e d � � Z e d � � Z RS( s_ A helper class for 'concrete' declarative mappings. :class:`.ConcreteBase` will use the :func:`.polymorphic_union` function automatically, against all tables mapped as a subclass to this class. The function is called via the ``__declare_last__()`` function, which is essentially a hook for the :meth:`.after_configured` event. :class:`.ConcreteBase` produces a mapped table for the class itself. Compare to :class:`.AbstractConcreteBase`, which does not. Example:: from sqlalchemy.ext.declarative import ConcreteBase class Employee(ConcreteBase, Base): __tablename__ = 'employee' employee_id = Column(Integer, primary_key=True) name = Column(String(50)) __mapper_args__ = { 'polymorphic_identity':'employee', 'concrete':True} class Manager(Employee): __tablename__ = 'manager' employee_id = Column(Integer, primary_key=True) name = Column(String(50)) manager_data = Column(String(40)) __mapper_args__ = { 'polymorphic_identity':'manager', 'concrete':True} The name of the discriminator column used by :func:`.polymorphic_union` defaults to the name ``type``. To suit the use case of a mapping where an actual column in a mapped table is already named ``type``, the discriminator name can be configured by setting the ``_concrete_discriminator_name`` attribute:: class Employee(ConcreteBase, Base): _concrete_discriminator_name = '_concrete_discriminator' .. versionadded:: 1.3.19 Added the ``_concrete_discriminator_name`` attribute to :class:`_declarative.ConcreteBase` so that the virtual discriminator column name can be customized. .. versionchanged:: 1.4.2 The ``_concrete_discriminator_name`` attribute need only be placed on the basemost class to take correct effect for all subclasses. An explicit error message is now raised if the mapped column names conflict with the discriminator name, whereas in the 1.3.x series there would be some warnings and then a non-useful query would be generated. .. seealso:: :class:`.AbstractConcreteBase` :ref:`concrete_inheritance` c C s t t d � | D� � | d � S( Nc s s! | ] } | j | j f Vq d S( N( t polymorphic_identityt local_table( t .0t mp( ( sX /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/declarative/extensions.pys <genexpr>l s t pjoin( R R ( R t mapperst discriminator_name( ( sX /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/declarative/extensions.pyt _create_polymorphic_unionh s c C sz | j } | j r d St | d d � p+ d } t | j � } | j | | � } | j d | f � | j | j | � d S( Nt _concrete_discriminator_namet typet *( t __mapper__t with_polymorphict getattrt Nonet listt self_and_descendantsR t _set_with_polymorphict _set_polymorphic_ont c( R t mR R R ( ( sX /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/declarative/extensions.pyt __declare_first__r s ( t __name__t __module__t __doc__t classmethodR R'