/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext
NameSizeModeActions
declarative/-0755rm
associationproxy.py494630644editdlrm
associationproxy.pyc634560644editdlrm
associationproxy.pyo633810644editdlrm
automap.py417100644editdlrm
automap.pyc369150644editdlrm
automap.pyo369150644editdlrm
baked.py214690644editdlrm
baked.pyc248090644editdlrm
baked.pyo248090644editdlrm
compiler.py168500644editdlrm
compiler.pyc171090644editdlrm
compiler.pyo171090644editdlrm
horizontal_shard.py91090644editdlrm
horizontal_shard.pyc93740644editdlrm
horizontal_shard.pyo93350644editdlrm
hybrid.py402330644editdlrm
hybrid.pyc435660644editdlrm
hybrid.pyo435660644editdlrm
indexable.py111690644editdlrm
indexable.pyc114560644editdlrm
indexable.pyo114560644editdlrm
instrumentation.py143510644editdlrm
instrumentation.pyc176480644editdlrm
instrumentation.pyo176480644editdlrm
mutable.py318080644editdlrm
mutable.pyc391390644editdlrm
mutable.pyo391390644editdlrm
orderinglist.py138880644editdlrm
orderinglist.pyc163190644editdlrm
orderinglist.pyo163190644editdlrm
serializer.py57840644editdlrm
serializer.pyc60480644editdlrm
serializer.pyo60480644editdlrm
__init__.py3220644editdlrm
__init__.pyc2890644editdlrm
__init__.pyo2890644editdlrm
Edit: /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/orderinglist.pyc (16319B)
ó ÃÌ4]c@s’dZddlmZddlmZddlmZdgZdd„Zd„Z d„Z d „Z d „Z d e fd „ƒYZd „ZdS(s½A custom list that manages index/position information for contained elements. :author: Jason Kirtland ``orderinglist`` is a helper for mutable ordered relationships. It will intercept list operations performed on a :func:`.relationship`-managed collection and automatically synchronize changes in list position onto a target scalar attribute. Example: A ``slide`` table, where each row refers to zero or more entries in a related ``bullet`` table. The bullets within a slide are displayed in order based on the value of the ``position`` column in the ``bullet`` table. As entries are reordered in memory, the value of the ``position`` attribute should be updated to reflect the new sort order:: Base = declarative_base() class Slide(Base): __tablename__ = 'slide' id = Column(Integer, primary_key=True) name = Column(String) bullets = relationship("Bullet", order_by="Bullet.position") class Bullet(Base): __tablename__ = 'bullet' id = Column(Integer, primary_key=True) slide_id = Column(Integer, ForeignKey('slide.id')) position = Column(Integer) text = Column(String) The standard relationship mapping will produce a list-like attribute on each ``Slide`` containing all related ``Bullet`` objects, but coping with changes in ordering is not handled automatically. When appending a ``Bullet`` into ``Slide.bullets``, the ``Bullet.position`` attribute will remain unset until manually assigned. When the ``Bullet`` is inserted into the middle of the list, the following ``Bullet`` objects will also need to be renumbered. The :class:`.OrderingList` object automates this task, managing the ``position`` attribute on all ``Bullet`` objects in the collection. It is constructed using the :func:`.ordering_list` factory:: from sqlalchemy.ext.orderinglist import ordering_list Base = declarative_base() class Slide(Base): __tablename__ = 'slide' id = Column(Integer, primary_key=True) name = Column(String) bullets = relationship("Bullet", order_by="Bullet.position", collection_class=ordering_list('position')) class Bullet(Base): __tablename__ = 'bullet' id = Column(Integer, primary_key=True) slide_id = Column(Integer, ForeignKey('slide.id')) position = Column(Integer) text = Column(String) With the above mapping the ``Bullet.position`` attribute is managed:: s = Slide() s.bullets.append(Bullet()) s.bullets.append(Bullet()) s.bullets[1].position >>> 1 s.bullets.insert(1, Bullet()) s.bullets[2].position >>> 2 The :class:`.OrderingList` construct only works with **changes** to a collection, and not the initial load from the database, and requires that the list be sorted when loaded. Therefore, be sure to specify ``order_by`` on the :func:`.relationship` against the target ordering attribute, so that the ordering is correct when first loaded. .. warning:: :class:`.OrderingList` only provides limited functionality when a primary key column or unique column is the target of the sort. Operations that are unsupported or are problematic include: * two entries must trade values. This is not supported directly in the case of a primary key or unique constraint because it means at least one row would need to be temporarily removed first, or changed to a third, neutral value while the switch occurs. * an entry must be deleted in order to make room for a new entry. SQLAlchemy's unit of work performs all INSERTs before DELETEs within a single flush. In the case of a primary key, it will trade an INSERT/DELETE of the same primary key for an UPDATE statement in order to lessen the impact of this limitation, however this does not take place for a UNIQUE column. A future feature will allow the "DELETE before INSERT" behavior to be possible, alleviating this limitation, though this feature will require explicit configuration at the mapper level for sets of columns that are to be handled in this way. :func:`.ordering_list` takes the name of the related object's ordering attribute as an argument. By default, the zero-based integer index of the object's position in the :func:`.ordering_list` is synchronized with the ordering attribute: index 0 will get position 0, index 1 position 1, etc. To start numbering at 1 or some other integer, provide ``count_from=1``. i(tutil(t collection(tcollection_adaptert ordering_listc s"td|ˆ‰‡‡fd†S(sPrepares an :class:`OrderingList` factory for use in mapper definitions. Returns an object suitable for use as an argument to a Mapper relationship's ``collection_class`` option. e.g.:: from sqlalchemy.ext.orderinglist import ordering_list class Slide(Base): __tablename__ = 'slide' id = Column(Integer, primary_key=True) name = Column(String) bullets = relationship("Bullet", order_by="Bullet.position", collection_class=ordering_list('position')) :param attr: Name of the mapped attribute to use for storage and retrieval of ordering information :param count_from: Set up an integer-based ordering, starting at ``count_from``. For example, ``ordering_list('pos', count_from=1)`` would create a 1-based list in SQL, storing the value in the 'pos' column. Ignored if ``ordering_func`` is supplied. Additional arguments are passed to the :class:`.OrderingList` constructor. t count_fromcs tˆˆS(N(t OrderingList((tattrtkw(sN/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/orderinglist.pyt¢t(t_unsugar_count_from(RRR((RRsN/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/orderinglist.pyR‚scCs|S(s7Numbering function: consecutive integers starting at 0.((tindexR((sN/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/orderinglist.pyt count_from_0¨scCs|dS(s7Numbering function: consecutive integers starting at 1.i((R R((sN/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/orderinglist.pyt count_from_1®scs8‡fd†}ydˆ|_Wntk r3nX|S(sENumbering function: consecutive integers starting at arbitrary start.cs|ˆS(N((R R(tstart(sN/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/orderinglist.pytf·ss count_from_%i(t__name__t TypeError(RR((RsN/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/orderinglist.pytcount_from_n_factory´s  cKs|jddƒ}|jddƒdkr{|dk r{|dkrOt|d|jr>|jƒndS(N(R'RtremoveRt_referenced_by_ownerR,(RRtadapter((sN/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/orderinglist.pyR-Es iÿÿÿÿcCs&tt|ƒj|ƒ}|jƒ|S(N(R'RRR,(RR R((sN/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/orderinglist.pyRLs cCsät|tƒr´|jpd}|jp*d}|dkrL|t|ƒ7}n|jp^t|ƒ}|dkr€|t|ƒ7}nx]t|||ƒD]}|j|||ƒq“Wn,|j||t ƒt t |ƒj||ƒdS(Nii( t isinstancetslicetstepRR)tstoptranget __setitem__R"R#R'R(RR RR2RR3ti((sN/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/orderinglist.pyR5Qs  cCs$tt|ƒj|ƒ|jƒdS(N(R'Rt __delitem__R,(RR ((sN/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/orderinglist.pyR7ascCs*tt|ƒj|||ƒ|jƒdS(N(R'Rt __setslice__R,(RRtendtvalues((sN/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/orderinglist.pyR8escCs'tt|ƒj||ƒ|jƒdS(N(R'Rt __delslice__R,(RRR9((sN/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/orderinglist.pyR;iscCst|j|jt|ƒffS(N(t _reconstitutet __class__t__dict__tlist(R((sN/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/orderinglist.pyt __reduce__msN(!Rt __module__t__doc__RtFalseRRR R$R,R#R"R(R*RtaddsR+R-RR5R7R8R;R@R?tlocalstitemst func_nametfuncRtcallablethasattrR(((sN/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/orderinglist.pyRÓs2;             " cCs3|j|ƒ}|jj|ƒtj||ƒ|S(s« Reconstitute an :class:`.OrderingList`. This is the adjoint to :meth:`.OrderingList.__reduce__`. It is used for unpickling :class:`.OrderingList` objects. (t__new__R>tupdateR?textend(tclstdict_RFtobj((sN/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/orderinglist.pyR<{sN(RBR Rtorm.collectionsRRt__all__RRR R RR R?RR<(((sN/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/orderinglist.pytys  &   ¨