%PDF- %PDF-
Direktori : /proc/self/root/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/ |
Current File : //proc/self/root/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_json.pyc |
� �ac @ s� d Z d d l Z d d l m Z m Z d d l m Z m Z m Z d d l m Z d Z d Z d Z d Z d e f d � � YZ d e d d d d d � Z d e d d � Z d e d d � Z d d d � Z d d � Z d S( 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( t new_typet new_array_typet register_type( t PY2ir i� i� i� t Jsonc B sY e Z d Z d d � Z d � Z d � Z d � Z d � Z e rN d � Z n d � Z RS( 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. c C s( | | _ d | _ | p t j | _ d S( N( t adaptedt Nonet _connt jsont dumpst _dumps( t selfR R ( ( sE /opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_json.pyt __init__8 s c C s | t k r | Sd S( N( R ( R t proto( ( sE /opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_json.pyt __conform__= s c C s | j | � S( 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. ( R ( R t obj( ( sE /opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_json.pyR A s c C s | | _ d S( N( R ( R t conn( ( sE /opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_json.pyt prepareJ s c C sJ | j | j � } t | � } | j d k r@ | j | j � n | j � S( N( R R R R R R t getquoted( R t st qs( ( sE /opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_json.pyR M s c C s | j � S( N( R ( R ( ( sE /opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_json.pyt __str__U s c C s | j � j d d � S( Nt asciit replace( R t decode( R ( ( sE /opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_json.pyR X s N( t __name__t __module__t __doc__R R R R R R R R ( ( ( sE /opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_json.pyR . s R c C s� | d k r$ t | | � \ } } n t | | d | d | j � �\ } } t | | r^ | pa d � | d k r� t | | r� | p� d � n | | f S( s Create 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. t loadst nameN( R t _get_json_oidst _create_json_typecasterst upperR ( t conn_or_curst globallyR t oidt array_oidR t JSONt JSONARRAY( ( sE /opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_json.pyt register_json] s $c C s% t d | d | d | d t d t � 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()`. R# R$ R R% R&