HEX
Server: LiteSpeed
System: Linux standart9.isimtescil.net 3.10.0-962.3.2.lve1.5.26.7.el7.x86_64 #1 SMP Wed Oct 2 07:53:12 EDT 2019 x86_64
User: karalev (5310)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //proc/self/root/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyo
�
��4]c@s^dZddlmZddlmZddlmZddlmZddlmZddlm	Z	e
Ze
Ze
Z
e
Ze
Ze
Ze
Zd	efd
��YZde	jefd��YZd
e	jee�fd��YZdefd��YZdefd��YZdeefd��YZdefd��YZd�Zd�Zd�ZdS(sBase types API.

i(t	operators(tSchemaEventTarget(t	Visitable(t
VisitableTypei(texc(tutilt
TypeEnginecBs�eZdZeZeZdejfd��YZ	eZ
e	ZeZd�Z
d�Zd�Zd�Zd�Zd�Zd	�Zd
�Zejd��Zd�Zejd
��Zed��Zd�Zd�Zed��Zd�Z ejd��Z!d�Z"d�Z#d�Z$d�Z%d�Z&d�Z'd�Z(d�Z)d�Z*d�Z+d�Z,d$d�Z.ej/d �d!��Z0d"�Z1d#�Z2RS(%s1The ultimate base class for all SQL datatypes.

    Common subclasses of :class:`.TypeEngine` include
    :class:`.String`, :class:`.Integer`, and :class:`.Boolean`.

    For an overview of the SQLAlchemy typing system, see
    :ref:`types_toplevel`.

    .. seealso::

        :ref:`types_toplevel`

    t
ComparatorcBseeZdZd	Zd
Zd�Zejd�d��Z	ejd�d��Z
d�Zd�ZRS(s�Base class for custom comparison operations defined at the
        type level.  See :attr:`.TypeEngine.comparator_factory`.


        texprttypecCs||_|j|_dS(N(RR	(tselfR((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyt__init__<s	s!sqlalchemy.sql.default_comparatorcOs2|j|j}|d|j|||d|�S(Nii(toperator_lookupt__name__R(R
tdefault_comparatortoptothertkwargsto((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pytoperate@scKs7|j|j}|d|j||dt|d|�S(Nitreversei(RR
RtTrue(R
RRRRR((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pytreverse_operateEscCs
||jfS(s<evaluate the return type of <self> <op> <othertype>,
            and apply any adaptations to the given operator.

            This method determines the type of a resulting binary expression
            given two source types and an operator.   For example, two
            :class:`.Column` objects, both of the type :class:`.Integer`, will
            produce a :class:`.BinaryExpression` that also has the type
            :class:`.Integer` when compared via the addition (``+``) operator.
            However, using the addition operator with an :class:`.Integer`
            and a :class:`.Date` object will produce a :class:`.Date`, assuming
            "days delta" behavior by the database (in reality, most databases
            other than PostgreSQL don't accept this particular operation).

            The method returns a tuple of the form <operator>, <type>.
            The resulting operator and type will be those applied to the
            resulting :class:`.BinaryExpression` as the final operator and the
            right-hand side of the expression.

            Note that only a subset of operators make usage of
            :meth:`._adapt_expression`,
            including math operators and user-defined operators, but not
            boolean comparison or special SQL keywords like MATCH or BETWEEN.

            (R	(R
Rtother_comparator((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyt_adapt_expressionJscCst|jffS(N(t_reconstitute_comparatorR(R
((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyt
__reduce__fs(RR	N(
R
t
__module__t__doc__t	__slots__tNoneRRRtdependenciesRRRR(((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR1s		cCs|j�}t|_|S(s�Return a copy of this type which has the :attr:`.should_evaluate_none`
        flag set to True.

        E.g.::

                Table(
                    'some_table', metadata,
                    Column(
                        String(50).evaluates_none(),
                        nullable=True,
                        server_default='no value')
                )

        The ORM uses this flag to indicate that a positive value of ``None``
        is passed to the column in an INSERT statement, rather than omitting
        the column from the INSERT statement which has the effect of firing
        off column-level defaults.   It also allows for types which have
        special behavior associated with the Python None value to indicate
        that the value doesn't necessarily translate into SQL NULL; a
        prime example of this is a JSON type which may wish to persist the
        JSON value ``'null'``.

        In all cases, the actual NULL SQL value can be always be
        persisted in any column by using
        the :obj:`~.expression.null` SQL construct in an INSERT statement
        or associated with an ORM-mapped attribute.

        .. note::

            The "evaluates none" flag does **not** apply to a value
            of ``None`` passed to :paramref:`.Column.default` or
            :paramref:`.Column.server_default`; in these cases, ``None``
            still means "no default".

        .. versionadded:: 1.1

        .. seealso::

            :ref:`session_forcing_null` - in the ORM documentation

            :paramref:`.postgresql.JSON.none_as_null` - PostgreSQL JSON
            interaction with this flag.

            :attr:`.TypeEngine.should_evaluate_none` - class-level flag

        (tcopyRtshould_evaluate_none(R
ttyp((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pytevaluates_none�s/	cKs|j|j�S(N(tadaptt	__class__(R
tkw((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR �scCsdS(s�Compare this type against the given backend type.

        This function is currently not implemented for SQLAlchemy
        types, and for all built in types will return ``None``.  However,
        it can be implemented by a user-defined type
        where it can be consumed by schema comparison tools such as
        Alembic autogenerate.

        A future release of SQLAlchemy will potentially implement this method
        for builtin types as well.

        The function should return True if this type is equivalent to the
        given type; the type is typically reflected from the database
        so should be database specific.  The dialect in use is also
        passed.   It can also return False to assert that the type is
        not equivalent.

        :param dialect: a :class:`.Dialect` that is involved in the comparison.

        :param conn_type: the type object reflected from the backend.

        .. versionadded:: 1.0.3

        N(R(R
tdialectt	conn_type((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pytcompare_against_backend�scCs|S(N((R
tvalue((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyt
copy_value�scCsdS(szReturn a conversion function for processing literal values that are
        to be rendered directly without using binds.

        This function is used when the compiler makes use of the
        "literal_binds" flag, typically used in DDL generation as well
        as in certain scenarios where backends don't accept bound parameters.

        .. versionadded:: 0.9.0

        N(R(R
R'((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pytliteral_processor�scCsdS(seReturn a conversion function for processing bind values.

        Returns a callable which will receive a bind parameter value
        as the sole positional argument and will return a value to
        send to the DB-API.

        If processing is not necessary, the method should return ``None``.

        :param dialect: Dialect instance in use.

        N(R(R
R'((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pytbind_processor�scCsdS(s�Return a conversion function for processing result row values.

        Returns a callable which will receive a result row column
        value as the sole positional argument and will return a value
        to return to the user.

        If processing is not necessary, the method should return ``None``.

        :param dialect: Dialect instance in use.

        :param coltype: DBAPI coltype argument received in cursor.description.

        N(R(R
R'tcoltype((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pytresult_processor
scCsdS(s�Given a SELECT column expression, return a wrapping SQL expression.

        This is typically a SQL function that wraps a column expression
        as rendered in the columns clause of a SELECT statement.
        It is used for special data types that require
        columns to be wrapped in some special database function in order
        to coerce the value before being sent back to the application.
        It is the SQL analogue of the :meth:`.TypeEngine.result_processor`
        method.

        The method is evaluated at statement compile time, as opposed
        to statement construction time.

        .. seealso::

            :ref:`types_sql_value_processing`

        N(R(R
tcolexpr((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pytcolumn_expressionscCs|jjjtjjk	S(s�memoized boolean, check if column_expression is implemented.

        Allows the method to be skipped for the vast majority of expression
        types that don't use this feature.

        (R%R1t__code__R(R
((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyt_has_column_expression3s
cCsdS(s�"Given a bind value (i.e. a :class:`.BindParameter` instance),
        return a SQL expression in its place.

        This is typically a SQL function that wraps the existing bound
        parameter within the statement.  It is used for special data types
        that require literals being wrapped in some special database function
        in order to coerce an application-level value into a database-specific
        format.  It is the SQL analogue of the
        :meth:`.TypeEngine.bind_processor` method.

        The method is evaluated at statement compile time, as opposed
        to statement construction time.

        Note that this method, when implemented, should always return
        the exact same structure, without any conditional logic, as it
        may be used in an executemany() call against an arbitrary number
        of bound parameter sets.

        .. seealso::

            :ref:`types_sql_value_processing`

        N(R(R
t	bindvalue((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pytbind_expressionAscCs|jjjtjjk	S(s�memoized boolean, check if bind_expression is implemented.

        Allows the method to be skipped for the vast majority of expression
        types that don't use this feature.

        (R%R5R2R(R
((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyt_has_bind_expression[s
cCs
t|�S(N(tto_instance(tcls_or_self((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyt_to_instanceiscCs
||kS(s Compare two values for equality.((R
txty((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pytcompare_valuesmscCsdS(s�Return the corresponding type object from the underlying DB-API, if
        any.

         This can be useful for calling ``setinputsizes()``, for example.

        N(R(R
tdbapi((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pytget_dbapi_typerscCs
t��dS(sReturn the Python type object expected to be returned
        by instances of this type, if known.

        Basically, for those types which enforce a return type,
        or are known across the board to do such for all common
        DBAPIs (like ``int`` for example), will return that type.

        If a return type is not defined, raises
        ``NotImplementedError``.

        Note that any type also accommodates NULL in SQL which
        means you can also get back ``None`` from any type
        in practice.

        N(tNotImplementedError(R
((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pytpython_type{scCst|it|�|6�S(s�Produce a new type object that will utilize the given
        type when applied to the dialect of the given name.

        e.g.::

            from sqlalchemy.types import String
            from sqlalchemy.dialects import mysql

            s = String()

            s = s.with_variant(mysql.VARCHAR(collation='foo'), 'mysql')

        The construction of :meth:`.TypeEngine.with_variant` is always
        from the "fallback" type to that which is dialect specific.
        The returned type is an instance of :class:`.Variant`, which
        itself provides a :meth:`.Variant.with_variant`
        that can be called repeatedly.

        :param type\_: a :class:`.TypeEngine` that will be selected
         as a variant from the originating type, when a dialect
         of the given name is in use.
        :param dialect_name: base name of the dialect which uses
         this type. (i.e. ``'postgresql'``, ``'mysql'``, etc.)

        (tVariantR7(R
ttype_tdialect_name((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pytwith_variant�scCs\d}xO|jjD]:}|ttfkr/|St|ttf�r|}qqW|jSdS(sRReturn a rudimental 'affinity' value expressing the general class
        of type.N(RR%t__mro__RtUserDefinedTypet
issubclass(R
R"tt((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyt_type_affinity�s
cCs9y|j|dSWntk
r4|j|�dSXdS(sYReturn a dialect-specific implementation for this
        :class:`.TypeEngine`.

        timplN(t_type_memostKeyErrort
_dialect_info(R
R'((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pytdialect_impl�s
cCs
|j|�S(s�Return the 'unwrapped' dialect impl for this type.

        For a type that applies wrapping logic (e.g. TypeDecorator), give
        us the real, actual dialect-level type that is used.

        This is used by TypeDecorator itself as well at least one case where
        dialects need to check that a particular specific dialect-level
        type is in use, within the :meth:`.DefaultDialect.set_input_sizes`
        method.

        (RN(R
R'((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyt_unwrapped_dialect_impl�scCsVy|j|dSWn<tk
rQ|j|�}|dj|�|d<}|SXdS(s:Return a dialect-specific literal processor for this type.tliteralRJN(RKRLRMR,(R
R'tdtlp((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyt_cached_literal_processor�s
cCsVy|j|dSWn<tk
rQ|j|�}|dj|�|d<}|SXdS(s7Return a dialect-specific bind processor for this type.tbindRJN(RKRLRMR-(R
R'RQtbp((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyt_cached_bind_processor�s
cCsYy|j||SWn?tk
rT|j|�}|dj||�||<}|SXdS(s9Return a dialect-specific result processor for this type.RJN(RKRLRMR/(R
R'R.RQtrp((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyt_cached_result_processor�s
cCsYy|j||SWn?tk
rT|j|�}|d}||�||<}|SXdS(NRJ(RKRLRM(R
R'tkeytfnRQRJtresult((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyt_cached_custom_processor�s

cCsm||jkr|j|S|j|�}||krM|jt|��}ni|d6|j|<}|SdS(s�Return a dialect-specific registry which
        caches a dialect-specific implementation, bind processing
        function, and one or more result processing functions.RJN(RKt_gen_dialect_implR$R	(R
R'RJRQ((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyRM�scCs
|j|�S(N(ttype_descriptor(R
R'((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR]	scKstj|||�S(s�Produce an "adapted" form of this type, given an "impl" class
        to work with.

        This method is used internally to associate generic
        types with "implementation" types that are specific to a particular
        dialect.
        (Rtconstructor_copy(R
tclsR&((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR$scCs6t|�}|tks*|j|jkr.|S|SdS(soSuggest a type for a 'coerced' Python value in an expression.

        Given an operator and value, gives the type a chance
        to return a type which the value should be coerced into.

        The default behavior here is conservative; if the right-hand
        side is already coerced into a SQL type based on its
        Python type, it is usually left alone.

        End-user functionality extension here should generally be via
        :class:`.TypeDecorator`, which provides more liberal behavior in that
        it defaults to coercing the other side of the expression into this
        type, thus applying special Python conversions above and beyond those
        needed by the DBAPI to both ides. It also provides the public method
        :meth:`.TypeDecorator.coerce_compared_value` which is intended for
        end-user customization of this behavior.

        N(t_resolve_value_to_typetNULLTYPERI(R
RR*t
_coerced_type((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pytcoerce_compared_values
cCs|j|jkS(N(RI(R
R((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyt_compare_type_affinity2scCs%|s|j�}n|jj|�S(s�Produce a string-compiled form of this :class:`.TypeEngine`.

        When called with no arguments, uses a "default" dialect
        to produce a string result.

        :param dialect: a :class:`.Dialect` instance.

        (t_default_dialectt
type_compilertprocess(R
R'((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pytcompile5sssqlalchemy.engine.defaultcCsn|jjjd�r`|jjjd�dd!}dj|�}tt|�j|d�j�S|j	�SdS(Nssqlalchemy.dialectst.iii����(
R%Rt
startswithtsplittjointgetattrt
__import__tdialectsR'tDefaultDialect(R
tdefaultttokenstmod((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyRfFs
 cCs9tjr%t|j��jdd�St|j��SdS(Ntasciitbackslashreplace(Rtpy2ktunicodeRitencodetstr(R
((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyt__str__Os	
cCs
tj|�S(N(Rtgeneric_repr(R
((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyt__repr__WsN(3R
RRRt
_sqla_typetFalset_isnullRtColumnOperatorsRthashabletcomparator_factoryR!R#R R)R+R,R-R/R1Rtmemoized_propertyR3R5R6tstaticmethodR9R<R>tpropertyR@RDRIRNRORSRVRXR\RMR]R$RdReRRiRRfR{R}(((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyRsN
8	3				
									
				
	
					
				tVisitableCheckKWArgcBseZRS((R
R(((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR�[sRFcBsBeZdZdZdZdejfd��YZeZd�ZRS(sBase for user defined types.

    This should be the base of new types.  Note that
    for most cases, :class:`.TypeDecorator` is probably
    more appropriate::

      import sqlalchemy.types as types

      class MyType(types.UserDefinedType):
          def __init__(self, precision = 8):
              self.precision = precision

          def get_col_spec(self, **kw):
              return "MYTYPE(%s)" % self.precision

          def bind_processor(self, dialect):
              def process(value):
                  return value
              return process

          def result_processor(self, dialect, coltype):
              def process(value):
                  return value
              return process

    Once the type is made, it's immediately usable::

      table = Table('foo', meta,
          Column('id', Integer, primary_key=True),
          Column('data', MyType(16))
          )

    The ``get_col_spec()`` method will in most cases receive a keyword
    argument ``type_expression`` which refers to the owning expression
    of the type as being compiled, such as a :class:`.Column` or
    :func:`.cast` construct.  This keyword is only sent if the method
    accepts keyword arguments (e.g. ``**kw``) in its argument signature;
    introspection is used to check for this in order to support legacy
    forms of this function.

    .. versionadded:: 1.0.0 the owning expression is passed to
       the ``get_col_spec()`` method via the keyword argument
       ``type_expression``, if it receives ``**kw`` in its signature.

    tuser_definedtget_col_specRcBseZdZd�ZRS(cCsXt|jd�r8tjd�|jj|�|jfSttj|�j||�SdS(Ntadapt_operators�UserDefinedType.adapt_operator is deprecated.  Create a UserDefinedType.Comparator subclass instead which generates the desired expression constructs, given a particular operator.(	thasattrR	Rtwarn_deprecatedR�tsuperRFRR(R
RR((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR�s((R
RRR(((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR�scCs|S(s�Suggest a type for a 'coerced' Python value in an expression.

        Default behavior for :class:`.UserDefinedType` is the
        same as that of :class:`.TypeDecorator`; by default it returns
        ``self``, assuming the compared value should be coerced into
        the same type as this one.  See
        :meth:`.TypeDecorator.coerce_compared_value` for more detail.

        ((R
RR*((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyRd�s(	R
RRt__visit_name__tensure_kwargRRR�Rd(((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyRF_s-tEmulatedcBs eZdZd�Zd�ZRS(s�Mixin for base types that emulate the behavior of a DB-native type.

    An :class:`.Emulated` type will use an available database type
    in conjunction with Python-side routines and/or database constraints
    in order to approximate the behavior of a database type that is provided
    natively by some backends.  When a native-providing backend is in
    use, the native version of the type is used.  This native version
    should include the :class:`.NativeForEmulated` mixin to allow it to be
    distinguished from :class:`.Emulated`.

    Current examples of :class:`.Emulated` are:  :class:`.Interval`,
    :class:`.Enum`, :class:`.Boolean`.

    .. versionadded:: 1.2.0b3

    cKstt|�j||�S(sGiven an impl class, adapt this type to the impl assuming "emulated".

        The impl should also be an "emulated" version of this type,
        most likely the same class as this type itself.

        e.g.: sqltypes.Enum adapts to the Enum class.

        (R�R�R$(R
timpltypeR&((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pytadapt_to_emulated�s	cKsst|d�r4|jr(|j||�S|j}nt||j�rV|j||�Stt|�j||�SdS(Ntadapt_emulated_to_native(	R�tnativeR�R%RGR�R�R�R$(R
R�R&((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR$�s	(R
RRR�R$(((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR��s	tNativeForEmulatedcBseZdZed��ZRS(sgIndicates DB-native types supported by an :class:`.Emulated` type.

    .. versionadded:: 1.2.0b3

    cKs
||�S(s�Given an impl, adapt this type's class to the impl assuming "native".

        The impl will be an :class:`.Emulated` class but not a
        :class:`.NativeForEmulated`.

        e.g.: postgresql.ENUM produces a type given an Enum instance.

        ((R`RJR&((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR��s
(R
RRtclassmethodR�(((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR��st
TypeDecoratorcBsneZdZdZd�ZejfZdej	fd��YZ	e
d��Zd�Ze
d��Z
d�Zd	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zejd��Zejd��Zd�Zd�Zejd��Zd�Zejd��Zd�Zejd��Z d�Z!d�Z"d�Z#d�Z$d�Z%d�Z&RS( s�Allows the creation of types which add additional functionality
    to an existing type.

    This method is preferred to direct subclassing of SQLAlchemy's
    built-in types as it ensures that all required functionality of
    the underlying type is kept in place.

    Typical usage::

      import sqlalchemy.types as types

      class MyType(types.TypeDecorator):
          '''Prefixes Unicode values with "PREFIX:" on the way in and
          strips it off on the way out.
          '''

          impl = types.Unicode

          def process_bind_param(self, value, dialect):
              return "PREFIX:" + value

          def process_result_value(self, value, dialect):
              return value[7:]

          def copy(self, **kw):
              return MyType(self.impl.length)

    The class-level "impl" attribute is required, and can reference any
    TypeEngine class.  Alternatively, the load_dialect_impl() method
    can be used to provide different type classes based on the dialect
    given; in this case, the "impl" variable can reference
    ``TypeEngine`` as a placeholder.

    Types that receive a Python type that isn't similar to the ultimate type
    used may want to define the :meth:`TypeDecorator.coerce_compared_value`
    method. This is used to give the expression system a hint when coercing
    Python objects into bind parameters within expressions. Consider this
    expression::

        mytable.c.somecol + datetime.date(2009, 5, 15)

    Above, if "somecol" is an ``Integer`` variant, it makes sense that
    we're doing date arithmetic, where above is usually interpreted
    by databases as adding a number of days to the given date.
    The expression system does the right thing by not attempting to
    coerce the "date()" value into an integer-oriented bind parameter.

    However, in the case of ``TypeDecorator``, we are usually changing an
    incoming Python type to something new - ``TypeDecorator`` by default will
    "coerce" the non-typed side to be the same type as itself. Such as below,
    we define an "epoch" type that stores a date value as an integer::

        class MyEpochType(types.TypeDecorator):
            impl = types.Integer

            epoch = datetime.date(1970, 1, 1)

            def process_bind_param(self, value, dialect):
                return (value - self.epoch).days

            def process_result_value(self, value, dialect):
                return self.epoch + timedelta(days=value)

    Our expression of ``somecol + date`` with the above type will coerce the
    "date" on the right side to also be treated as ``MyEpochType``.

    This behavior can be overridden via the
    :meth:`~TypeDecorator.coerce_compared_value` method, which returns a type
    that should be used for the value of the expression. Below we set it such
    that an integer value will be treated as an ``Integer``, and any other
    value is assumed to be a date and will be treated as a ``MyEpochType``::

        def coerce_compared_value(self, op, value):
            if isinstance(value, int):
                return Integer()
            else:
                return self

    .. warning::

       Note that the **behavior of coerce_compared_value is not inherited
       by default from that of the base type**.
       If the :class:`.TypeDecorator` is augmenting a
       type that requires special logic for certain types of operators,
       this method **must** be overridden.  A key example is when decorating
       the :class:`.postgresql.JSON` and :class:`.postgresql.JSONB` types;
       the default rules of :meth:`.TypeEngine.coerce_compared_value` should
       be used in order to deal with operators like index operations::

            class MyJsonType(TypeDecorator):
                impl = postgresql.JSON

                def coerce_compared_value(self, op, value):
                    return self.impl.coerce_compared_value(op, value)

       Without the above step, index operations such as ``mycol['foo']``
       will cause the index value ``'foo'`` to be JSON encoded.

    ttype_decoratorcOs@t|jd�s!td��nt|jj||�|_dS(s�Construct a :class:`.TypeDecorator`.

        Arguments sent here are passed to the constructor
        of the class assigned to the ``impl`` class level attribute,
        assuming the ``impl`` is a callable, and the resulting
        object is assigned to the ``self.impl`` instance attribute
        (thus overriding the class attribute of the same name).

        If the class level ``impl`` is not a callable (the unusual case),
        it will be assigned to the same instance attribute 'as-is',
        ignoring those arguments passed to the constructor.

        Subclasses can override this to customize the generation
        of ``self.impl`` entirely.

        RJsuTypeDecorator implementations require a class-level variable 'impl' which refers to the class of type being decoratedN(R�R%tAssertionErrorR7RJ(R
targsR((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR]sRcBs eZdZd�Zd�ZRS(cOs2|jjj|d<ttj|�j|||�S(Nt_python_is_types(RR	tcoerce_to_is_typesR�R�RR(R
RRR((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR�scKs2|jjj|d<ttj|�j|||�S(NR�(RR	R�R�R�RR(R
RRR((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR�s((R
RRRR(((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR�s	cCsEtj|jjjkr"|jjStdtj|jjfi�SdS(NtTDComparator(R�RRJR�RER	(R
((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR��s
cCsu|j|�}||k	r|S|j|�}|j�}t||j�shtd||jf��n||_|S(s
        #todo
        saType object %s does not properly implement the copy() method, it must return an object of type %s(R^ROR t
isinstanceR%R�RJ(R
R'tadaptedttypedescttt((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR]�s	cCs
|jjS(s
        #todo
        (RJRI(R
((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyRI�scCs?tt|�j|�t|jt�r;|jj|�ndS(sSupport SchemaEventTargetN(R�R�t_set_parentR�RJR(R
tcolumn((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR��scCs?tt|�j|�t|jt�r;|jj|�ndS(sSupport SchemaEventTargetN(R�R�t_set_parent_with_dispatchR�RJR(R
tparent((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR��scCs[|j|�}t|t|��s(|St|jt�rJ|jj|�S|j|�SdS(s�Return a dialect-specific :class:`.TypeEngine` instance
        for this :class:`.TypeDecorator`.

        In most cases this returns a dialect-adapted form of
        the :class:`.TypeEngine` type represented by ``self.impl``.
        Makes usage of :meth:`dialect_impl` but also traverses
        into wrapped :class:`.TypeDecorator` instances.
        Behavior can be customized here by overriding
        :meth:`load_dialect_impl`.

        N(R^R�R	RJR�ttype_enginetload_dialect_impl(R
R'R�((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR��scCs|jS(s�Return a :class:`.TypeEngine` object corresponding to a dialect.

        This is an end-user override hook that can be used to provide
        differing types depending on the given dialect.  It is used
        by the :class:`.TypeDecorator` implementation of :meth:`type_engine`
        to help determine what type should ultimately be returned
        for a given :class:`.TypeDecorator`.

        By default returns ``self.impl``.

        (RJ(R
R'((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR��scCs|j|�j|�S(s�Return the 'unwrapped' dialect impl for this type.

        For a type that applies wrapping logic (e.g. TypeDecorator), give
        us the real, actual dialect-level type that is used.

        This is used by TypeDecorator itself as well at least one case where
        dialects need to check that a particular specific dialect-level
        type is in use, within the :meth:`.DefaultDialect.set_input_sizes`
        method.

        (R�RN(R
R'((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyRO�scCst|j|�S(sMProxy all other undefined accessors to the underlying
        implementation.(RnRJ(R
RY((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyt__getattr__scCs
t��dS(s�Receive a literal parameter value to be rendered inline within
        a statement.

        This method is used when the compiler renders a
        literal value without using binds, typically within DDL
        such as in the "server default" of a column or an expression
        within a CHECK constraint.

        The returned string will be rendered into the output string.

        .. versionadded:: 0.9.0

        N(R?(R
R*R'((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pytprocess_literal_paramscCs
t��dS(sReceive a bound parameter value to be converted.

        Subclasses override this method to return the
        value that should be passed along to the underlying
        :class:`.TypeEngine` object, and from there to the
        DBAPI ``execute()`` method.

        The operation could be anything desired to perform custom
        behavior, such as transforming or serializing data.
        This could also be used as a hook for validating logic.

        This operation should be designed with the reverse operation
        in mind, which would be the process_result_value method of
        this class.

        :param value: Data to operate upon, of any type expected by
         this method in the subclass.  Can be ``None``.
        :param dialect: the :class:`.Dialect` in use.

        N(R?(R
R*R'((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pytprocess_bind_paramscCs
t��dS(s�Receive a result-row column value to be converted.

        Subclasses should implement this method to operate on data
        fetched from the database.

        Subclasses override this method to return the
        value that should be passed back to the application,
        given a value that is already processed by
        the underlying :class:`.TypeEngine` object, originally
        from the DBAPI cursor method ``fetchone()`` or similar.

        The operation could be anything desired to perform custom
        behavior, such as transforming or serializing data.
        This could also be used as a hook for validating logic.

        :param value: Data to operate upon, of any type expected by
         this method in the subclass.  Can be ``None``.
        :param dialect: the :class:`.Dialect` in use.

        This operation should be designed to be reversible by
        the "process_bind_param" method of this class.

        N(R?(R
R*R'((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pytprocess_result_value-scCs|jjjtjjk	S(s�memoized boolean, check if process_bind_param is implemented.

        Allows the base process_bind_param to raise
        NotImplementedError without needing to test an expensive
        exception throw.

        (R%R�R2R�(R
((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyt_has_bind_processorHscCs|jjjtjjk	S(sKmemoized boolean, check if process_literal_param is implemented.


        (R%R�R2R�(R
((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyt_has_literal_processorWscs�|jr|j�n|jr*|j�nd��r||jj����rf���fd�}n��fd�}|S|jj��SdS(slProvide a literal processing function for the given
        :class:`.Dialect`.

        Subclasses here will typically override
        :meth:`.TypeDecorator.process_literal_param` instead of this method
        directly.

        By default, this method makes use of
        :meth:`.TypeDecorator.process_bind_param` if that method is
        implemented, where :meth:`.TypeDecorator.process_literal_param` is
        not.  The rationale here is that :class:`.TypeDecorator` typically
        deals with Python conversions of data that are above the layer of
        database presentation.  With the value converted by
        :meth:`.TypeDecorator.process_bind_param`, the underlying type will
        then handle whether it needs to be presented to the DBAPI as a bound
        parameter or to the database as an inline SQL value.

        .. versionadded:: 0.9.0

        cs��|���S(N((R*(R'timpl_processort
process_param(sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyRh�scs
�|��S(N((R*(R'R�(sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyRh�sN(R�R�R�R�RRJR,(R
R'Rh((R'R�R�sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR,cs		csl|jrX|j�|jj����rB���fd�}n��fd�}|S|jj��SdS(s�Provide a bound value processing function for the
        given :class:`.Dialect`.

        This is the method that fulfills the :class:`.TypeEngine`
        contract for bound value conversion.   :class:`.TypeDecorator`
        will wrap a user-defined implementation of
        :meth:`process_bind_param` here.

        User-defined code can override this method directly,
        though its likely best to use :meth:`process_bind_param` so that
        the processing provided by ``self.impl`` is maintained.

        :param dialect: Dialect instance in use.

        This method is the reverse counterpart to the
        :meth:`result_processor` method of this class.

        cs��|���S(N((R*(R'R�R�(sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyRh�scs
�|��S(N((R*(R'R�(sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyRh�sN(R�R�RJR-(R
R'Rh((R'R�R�sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR-�s		cCs|jjjtjjk	S(s�memoized boolean, check if process_result_value is implemented.

        Allows the base process_result_value to raise
        NotImplementedError without needing to test an expensive
        exception throw.

        (R%R�R2R�(R
((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyt_has_result_processor�s
csr|jr[|j�|jj�|���rE���fd�}n��fd�}|S|jj�|�SdS(s�Provide a result value processing function for the given
        :class:`.Dialect`.

        This is the method that fulfills the :class:`.TypeEngine`
        contract for result value conversion.   :class:`.TypeDecorator`
        will wrap a user-defined implementation of
        :meth:`process_result_value` here.

        User-defined code can override this method directly,
        though its likely best to use :meth:`process_result_value` so that
        the processing provided by ``self.impl`` is maintained.

        :param dialect: Dialect instance in use.
        :param coltype: A SQLAlchemy data type

        This method is the reverse counterpart to the
        :meth:`bind_processor` method of this class.

        cs��|���S(N((R*(R'R�t
process_value(sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyRh�scs
�|��S(N((R*(R'R�(sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyRh�sN(R�R�RJR/(R
R'R.Rh((R'R�R�sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR/�s		cCs%|jjjtjjk	p$|jjS(N(R%R5R2R�RJR6(R
((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR6�scCs|jj|�S(N(RJR5(R
t	bindparam((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR5�scCs%|jjjtjjk	p$|jjS(s�memoized boolean, check if column_expression is implemented.

        Allows the method to be skipped for the vast majority of expression
        types that don't use this feature.

        (R%R1R2R�RJR3(R
((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR3�s
cCs|jj|�S(N(RJR1(R
R�((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR1scCs|S(s}Suggest a type for a 'coerced' Python value in an expression.

        By default, returns self.   This method is called by
        the expression system when an object using this type is
        on the left or right side of an expression against a plain Python
        object which does not yet have a SQLAlchemy type assigned::

            expr = table.c.somecolumn + 35

        Where above, if ``somecolumn`` uses this type, this method will
        be called with the value ``operator.add``
        and ``35``.  The return value is whatever SQLAlchemy type should
        be used for ``35`` for this particular operation.

        ((R
RR*((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyRdscKs,|jj|j�}|jj|j�|S(sGProduce a copy of this :class:`.TypeDecorator` instance.

        This is a shallow copy and is provided to fulfill part of
        the :class:`.TypeEngine` contract.  It usually does not
        need to be overridden unless the user-defined :class:`.TypeDecorator`
        has local state that should be deep-copied.

        (R%t__new__t__dict__tupdate(R
R&tinstance((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR s
cCs|jj|�S(s�Return the DBAPI type object represented by this
        :class:`.TypeDecorator`.

        By default this calls upon :meth:`.TypeEngine.get_dbapi_type` of the
        underlying "impl".
        (RJR>(R
R=((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR>%scCs|jj||�S(s�Given two values, compare them for equality.

        By default this calls upon :meth:`.TypeEngine.compare_values`
        of the underlying "impl", which in turn usually
        uses the Python equals operator ``==``.

        This function is used by the ORM to compare
        an original-loaded value with an intercepted
        "changed" value, to determine if a net change
        has occurred.

        (RJR<(R
R:R;((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR<.s
cCstj|d|j�S(Nt
to_inspect(RR|RJ(R
((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR}=s('R
RRR�RRtNoneTypeR�RRR�R�R]RIR�R�R�R�ROR�R�R�R�R�R�R�R,R-R�R/R6R5R3R1RdR R>R<R}(((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR��s@c												0	$	%							RAcBsSeZdZd�Zd�Zd�Zd�Zd�Zd�Ze	d��Z
RS(sA wrapping type that selects among a variety of
    implementations based on dialect in use.

    The :class:`.Variant` type is typically constructed
    using the :meth:`.TypeEngine.with_variant` method.

    .. seealso:: :meth:`.TypeEngine.with_variant` for an example of use.

    cCs||_||_dS(s�Construct a new :class:`.Variant`.

        :param base: the base 'fallback' type
        :param mapping: dictionary of string dialect names to
          :class:`.TypeEngine` instances.

        N(RJtmapping(R
tbaseR�((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyRLs	cCs0|jj||�}||jkr(|S|SdS(N(RJRd(R
toperatorR*R[((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyRdWscCs+|j|jkr |j|jS|jSdS(N(tnameR�RJ(R
R'((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR�^scCsbt|jt�r%|jj|�nx6|jj�D]%}t|t�r5|j|�q5q5WdS(sSupport SchemaEventTargetN(R�RJRR�R�tvalues(R
R�RJ((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR�ds
cCsbt|jt�r%|jj|�nx6|jj�D]%}t|t�r5|j|�q5q5WdS(sSupport SchemaEventTargetN(R�RJRR�R�R�(R
R�RJ((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR�ms
cCsN||jkr%tjd|��n|jj�}|||<t|j|�S(s�Return a new :class:`.Variant` which adds the given
        type + dialect name to the mapping, in addition to the
        mapping present in this :class:`.Variant`.

        :param type\_: a :class:`.TypeEngine` that will be selected
         as a variant from the originating type, when a dialect
         of the given name is in use.
        :param dialect_name: base name of the dialect which uses
         this type. (i.e. ``'postgresql'``, ``'mysql'``, etc.)

        s?Dialect '%s' is already present in the mapping for this Variant(R�Rt
ArgumentErrorR RARJ(R
RBRCR�((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyRDvs


cCs
|jjS(s5express comparison behavior in terms of the base type(RJR�(R
((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR��s(R
RRRRdR�R�R�RDR�R�(((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyRAAs									cCs|jS(N(t
comparator(t
expression((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR�scOs4|dkrtStj|�r,|||�S|SdS(N(RRbRtcallable(ttypeobjtargR&((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyR7�s

cCs�t|t�r|�}nxB|jjdd!D])}y||}PWq/tk
rWq/Xq/W|St|j|�rv|S|j|�S(Nii����(R�R	R%RERLRGR$(R�tcolspecsRHR�((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyt
adapt_type�s

N(RtRR�RtvisitorsRRRRRtBOOLEANTYPEtINTEGERTYPERbt
STRINGTYPEt	MATCHTYPEt	INDEXABLERaRtEnsureKWArgTypeR�twith_metaclassRFtobjectR�R�R�RARR7R�(((sJ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/type_api.pyt<module>
s6��>"T/��MQ