%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/227033/root/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/
Upload File :
Create Path :
Current File : //proc/227033/root/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_json.pyc

�

Tc@sdZddlZddlmZmZddlmZmZmZejd dkrfddl	Z	n*yddl
Z	Wnek
r�dZ	nXdZ
dZd	Zd
Zdefd��YZdedddd
d�Zdedd�Zdedd�Zddd�Zd
d�ZdS(s�Implementation of the JSON adaptation objects

This module exists to avoid a circular import problem: pyscopg2.extras depends
on psycopg2.extension, so I can't create the default JSON typecasters in
extensions importing register_json from extras.
i����N(t	ISQLQuotetQuotedString(tnew_typetnew_array_typet
register_typeiiiri�i�i�tJsoncBs5eZdZdd�Zd�Zd�Zd�ZRS(s�
    An `~psycopg2.extensions.ISQLQuote` wrapper to adapt a Python object to
    :sql:`json` data type.

    `!Json` can be used to wrap any object supported by the provided *dumps*
    function.  If none is provided, the standard :py:func:`json.dumps()` is
    used (`!simplejson` for Python < 2.6;
    `~psycopg2.extensions.ISQLQuote.getquoted()` will raise `!ImportError` if
    the module is not available).

    cCsI||_|dk	r!||_n$tdk	r<tj|_n	d|_dS(N(tadaptedtNonet_dumpstjsontdumps(tselfRR
((sA/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_json.pyt__init__Bs	cCs|tkr|SdS(N(R(Rtproto((sA/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_json.pyt__conform__LscCs/|j}|dk	r||�Std��dS(s�Serialize *obj* in JSON format.

        The default is to call `!json.dumps()` or the *dumps* function
        provided in the constructor. You can override this method to create a
        customized JSON wrapper.
        s>json module not available: you should provide a dumps functionN(RRtImportError(RtobjR
((sA/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_json.pyR
Ps
	
cCs"|j|j�}t|�j�S(N(R
RRt	getquoted(Rts((sA/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_json.pyR_sN(t__name__t
__module__t__doc__RRRR
R(((sA/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_json.pyR6s

		R	cCs�|dkr$t||�\}}nt||d|d|j��\}}t||r^|pad�|dk	r�t||r�|p�d�n||fS(sCreate and register typecasters converting :sql:`json` type to Python objects.

    :param conn_or_curs: a connection or cursor used to find the :sql:`json`
        and :sql:`json[]` oids; the typecasters are registered in a scope
        limited to this object, unless *globally* is set to `!True`. It can be
        `!None` if the oids are provided
    :param globally: if `!False` register the typecasters only on
        *conn_or_curs*, otherwise register them globally
    :param loads: the function used to parse the data into a Python object. If
        `!None` use `!json.loads()`, where `!json` is the module chosen
        according to the Python version (see above)
    :param oid: the OID of the :sql:`json` type if known; If not, it will be
        queried on *conn_or_curs*
    :param array_oid: the OID of the :sql:`json[]` array type if known;
        if not, it will be queried on *conn_or_curs*
    :param name: the name of the data type to look for in *conn_or_curs*

    The connection or cursor passed to the function will be used to query the
    database and look for the OID of the :sql:`json` type (or an alternative
    type if *name* if provided). No query is performed if *oid* and *array_oid*
    are provided.  Raise `~psycopg2.ProgrammingError` if the type is not found.

    tloadstnameN(Rt_get_json_oidst_create_json_typecasterstupperR(tconn_or_curstgloballyRtoidt	array_oidRtJSONt	JSONARRAY((sA/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_json.pyt
register_jsonds$cCs%td|d|d|dtdt�S(s{
    Create and register :sql:`json` typecasters for PostgreSQL 9.2 and following.

    Since PostgreSQL 9.2 :sql:`json` is a builtin type, hence its oid is known
    and fixed. This function allows specifying a customized *loads* function
    for the default :sql:`json` type without querying the database.
    All the parameters have the same meaning of `register_json()`.
    RRRRR(R!tJSON_OIDt
JSONARRAY_OID(RRR((sA/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_json.pytregister_default_json�s	c
Cs+td|d|d|dtdtdd�S(s^
    Create and register :sql:`jsonb` typecasters for PostgreSQL 9.4 and following.

    As in `register_default_json()`, the function allows to register a
    customized *loads* function for the :sql:`jsonb` type at its known oid for
    PostgreSQL 9.4 and following versions.  All the parameters have the same
    meaning of `register_json()`.
    RRRRRRtjsonb(R!t	JSONB_OIDtJSONBARRAY_OID(RRR((sA/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_json.pytregister_default_jsonb�s	Rcs��dkr3tdkr'td��q3tj�n�fd�}t|f||�}|dk	rt|fd||�}nd}||fS(s&Create typecasters for json data type.sno json module availablecs|dkrdS�|�S(N(R(Rtcur(R(sA/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_json.pyt
typecast_json�ss%sARRAYN(RR	RRRR(RRRRR*RR ((RsA/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_json.pyR�sc	Cs�ddlm}ddlm}||�\}}|j}|jdkrPdpSd}|jd||f�|j�}||kr�|jr�|j	�n|s�|j
d|��n|S(	Ni����(tSTATUS_IN_TRANSACTION(t_solve_conn_cursi�9ttyparraytNULLs6SELECT t.oid, %s FROM pg_type t WHERE t.typname = %%s;s%s data type not found(tpsycopg2.extensionsR+tpsycopg2.extrasR,tstatustserver_versiontexecutetfetchonet
autocommittrollbacktProgrammingError(	RRR+R,tconntcurstconn_statusR-tr((sA/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_json.pyR�s	
(ii(Rtsystpsycopg2._psycopgRRRRRtversion_infoR	t
simplejsonRRR"R#R&R'tobjectRtFalseR!R$R(RR(((sA/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_json.pyt<module>s(

.	%

Zerion Mini Shell 1.0