/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext
Edit: /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/horizontal_shard.pyo (9335B)
σ
ΓΜ4]c @ 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 g Z d e f d YZ d e
f d
YZ d e f d YZ d S(
s Horizontal sharding support.
Defines a rudimental 'horizontal sharding' system which allows a Session to
distribute queries and persistence operations across multiple databases.
For a usage example, see the :ref:`examples_sharding` example included in
the source distribution.
i ( t inspect( t util( t Query( t Sessiont ShardedSessiont ShardedQueryc B sG e Z d Z d Z d Z d Z d d d Z d d Z RS( c O sD t t | j | | | j j | _ | j j | _ d | _ d S( N( t superR t __init__t sessiont
id_choosert
query_choosert Nonet _shard_id( t selft argst kwargs( ( sR /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/horizontal_shard.pyR s c C s | j } | | _ | S( sΉ return a new query, limited to a single shard ID.
all subsequent operations with the returned query will
be against the single shard regardless of other state.
( t _cloneR ( R
t shard_idt q( ( sR /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/horizontal_shard.pyt set_shard" s c s f d } j d k r. | j S j d k rJ | j Sg } x* j D] } | j | | q` Wt | Sd S( Nc sT | j d < _ j d j d | j j j } j | S( NR t mapper( t
attributest identity_tokent _connection_from_sessiont _bind_mappert executet statementt _paramst instances( R t result( t contextR
( sR /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/horizontal_shard.pyt iter_for_shard. s
( R R R R
t extendt iter( R
R R t partialR ( ( R R
sR /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/horizontal_shard.pyt _execute_and_instances- s
c s f d } j d k r1 | j Sd } g } x= j D], } | | } | | j 7} | j | qM Wt | | Sd S( Nc s= j d d | d d t } | j j } | S( NR R t clauset close_with_result( R t TrueR R ( R t connR ( R R
t stmt( sR /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/horizontal_shard.pyt exec_for_shardC s i ( R R R
t rowcountt appendt
ShardedResult( R
R( R R) R* t resultsR R ( ( R R
R( sR /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/horizontal_shard.pyt
_execute_crudB s
c K s± | d k r. t t | j | | d | | S| j j | } | rX | j | } n xN | j | | D]: } t t | j | | d | | } | d k rk | Sqk Wd Sd S( sΏ override the default Query._identity_lookup method so that we
search for a given non-token primary key identity across all
possible identity tokens (e.g. shard ids).
R N( R R R t _identity_lookupR t queryt _set_lazyload_fromR ( R
R t primary_key_identityR t lazy_loaded_fromt kwR R t obj( ( sR /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/horizontal_shard.pyR/ Y s c sX f d } | d k r9 j d k r9 j } n t t j | | d | S( s© Override the default Query._get_impl() method so that we emit
a query to the DB for each possible identity token, if we don't
have one already.
c s~ j d k r | St j | } xL j | D]4 } j | } | | } | d k r> | Sq> Wd Sd S( N( R R R t to_listR R ( R0 R2 t identR R t o( t
db_load_fnR
( sR /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/horizontal_shard.pyt _db_load_fn s
R N( R R R R t _get_impl( R
R2 R9 R R: ( ( R9 R
sR /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/horizontal_shard.pyR; { s
N( t __name__t
__module__R R R# R. R R/ R; ( ( ( sR /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/horizontal_shard.pyR s R, c B s, e Z d Z d Z d Z e d Z RS( sΪ A value object that represents multiple :class:`.ResultProxy` objects.
This is used by the :meth:`.ShardedQuery._execute_crud` hook to return
an object that takes the place of the single :class:`.ResultProxy`.
Attribute include ``result_proxies``, which is a sequence of the
actual :class:`.ResultProxy` objects, as well as ``aggregate_rowcount``
or ``rowcount``, which is the sum of all the individual rowcount values.
.. versionadded:: 1.3
t result_proxiest aggregate_rowcountc C s | | _ | | _ d S( N( R> R? ( R
R> R? ( ( sR /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/horizontal_shard.pyR « s c C s | j S( N( R? ( R
( ( sR /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/horizontal_shard.pyR* ― s ( R> R? ( R<