Tc@sdZddlZddlZddlZddlZyddl Z Wn dZ nXddl Z ddl m ZddlmZddlmZddlmZddlmZdefd YZd efd YZd efd YZdefdYZdefdYZdefdYZdefdYZdefdYZ defdYZ!defdYZ"defdYZ#de"fdYZ$d e#fd!YZ%d"e&fd#YZ'ddd$Z(d%e&fd&YZ)ddd'Z*ddd(Z+d)Z,d*Z-d+e&fd,YZ.e/e/ddd-Z0d.e&fd/YZ1e/dd0Z2dd1l3m4Z4m5Z5m6Z6dd2l3m7Z7m8Z8dd3l9m:Z:m;Z;dd4l9m<Z<m=Z=m>Z>dd5l9m?Z?m@Z@mAZAdS(6sMiscellaneous goodies for psycopg2 This module is a generic place used to hold little helper functions and classes until a better place in the distribution is found. iN(t extensions(tcursor(t connection(tadapt(tbtDictCursorBasecBs>eZdZdZdZddZdZdZRS(s%Base class for all dict-like cursors.cOsdd|kr |d}|d=n tdtt|j||d|_d|_||_dS(Nt row_factorys;DictCursorBase can't be instantiated without a row factory.i(tNotImplementedErrortsuperRt__init__t_query_executedt _prefetchR(tselftargstkwargsR((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyR 1s      cCs\|jr!tt|j}n|jr7|jn|jsXtt|j}n|S(N(R RRtfetchoneR t _build_index(R tres((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyR=s    cCsb|jr$tt|j|}n|jr:|jn|js^tt|j|}n|S(N(R RRt fetchmanyR R(R tsizeR((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyRFs    cCs\|jr!tt|j}n|jr7|jn|jsXtt|j}n|S(N(R RRtfetchallR R(R R((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyROs    ccs|jr-tt|j}|j}n|jrC|jn|jsptt|j}|j}n|Vx|jVqxdS(N(R RRt__iter__tnextR R(R Rtfirst((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyRXs    N( t__name__t __module__t__doc__R RtNoneRRR(((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyR.s  tDictConnectioncBseZdZdZRS(s2A connection that uses `DictCursor` automatically.cOs)|jdttt|j||S(Ntcursor_factory(t setdefaultt DictCursorRRR(R R R((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyRis(RRRR(((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyRgsRcBs8eZdZdZddZddZdZRS(s<A cursor that keeps a list of column name -> index mappings.cOs0t|dR@RARBRDt_syst version_info(((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyR s2               tRealDictConnectioncBseZdZdZRS(s6A connection that uses `RealDictCursor` automatically.cOs)|jdttt|j||S(NR(RtRealDictCursorRRHR(R R R((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyRs(RRRR(((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyRHsRIcBs8eZdZdZddZddZdZRS(sQA cursor that uses a real dict as the base type for rows. Note that this cursor is extremely specialized and does not allow the normal access (using integer indices) to fetched data. If you need to access database rows both as a dictionary and a list, then use the generic `DictCursor` instead of `!RealDictCursor`. cOs0t|d>> nt_cur = conn.cursor(cursor_factory=psycopg2.extras.NamedTupleCursor) >>> rec = nt_cur.fetchone() >>> rec Record(id=1, num=100, data="abc'def") >>> rec[1] 100 >>> rec.data "abc'def" cCs"d|_tt|j||S(N(RtRecordRRSR"(R R#R$((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyR"s cCs"d|_tt|j||S(N(RRTRRSt executemany(R R#R$((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyRU"s cCs"d|_tt|j||S(N(RRTRRSR%(R R&R$((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyR%&s cCs]tt|j}|dk rY|j}|dkrL|j}|_n|j|SdS(N(RRSRRRTt_make_ntt_make(R tttnt((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyR*s    cCsStt|j|}|j}|dkrC|j}|_nt|j|S(N(RRSRRTRRVtmapRW(R RttsRY((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyR2s   cCsPtt|j}|j}|dkr@|j}|_nt|j|S(N(RRSRRTRRVRZRW(R R[RY((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyR9s   ccsxtt|j}|j}|j}|dkrL|j}|_n|j|Vx|j|jVq]dS(N(RRSRRRTRRVRW(R titRXRY((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyR@s   i(t namedtuplecCs |jdS(N(t_exc(R ((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyRVPscCs-|dg|jpdD]}|d^qS(NRTi((R'(R R]td((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyRVSsN(RRRRRTR"RUR%RRRRt collectionsR]t ImportErrorR^RV(((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyRS s        tLoggingConnectioncBsDeZdZdZdZdZdZdZdZRS(s}A connection that logs all queries to a file or logger__ object. .. __: http://docs.python.org/library/logging.html cCs@||_tr0t|tjr0|j|_n |j|_dS(sInitialize the connection to log to `!logobj`. The `!logobj` parameter can be an open file object or a Logger instance from the standard logging module. N(t_logobjt_loggingR,tLoggert _logtologgertlogt _logtofile(R tlogobj((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyt initialize]s cCs|S(sFilter the query before logging it. This is the method to overwrite to filter unwanted queries out of the log or to add some extra data to the output. The default implementation just does nothing. ((R tmsgtcurs((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pytfilteriscCs6|j||}|r2|jj|tjndS(N(RmRctwritet_ostlinesep(R RkRl((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyRhrscCs/|j||}|r+|jj|ndS(N(RmRctdebug(R RkRl((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyRfvscCs%t|ds!|jdndS(NRcs3LoggingConnection object has not been initialize()d(thasattrtProgrammingError(R ((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyt_checkzscOs3|j|jdttt|j||S(NR(RtRt LoggingCursorRRbR(R R R((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyRs ( RRRRjRmRhRfRtR(((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyRbWs   RucBs&eZdZddZddZRS(sCA cursor that logs queries using its connection logging facilities.cCs;ztt|j||SWd|jj|j|XdS(N(RRuR"RRgR#(R R#R$((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyR"scCs;ztt|j||SWd|jj|j|XdS(N(RRuR%RRgR#(R R&R$((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyR%sN(RRRRR"R%(((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyRus tMinTimeLoggingConnectioncBs,eZdZddZdZdZRS(sA connection that logs queries based on execution time. This is just an example of how to sub-class `LoggingConnection` to provide some extra filtering for the logged queries. Both the `initialize()` and `filter()` methods are overwritten to make sure that only queries executing for more than ``mintime`` ms are logged. Note that this connection uses the specialized cursor `MinTimeLoggingCursor`. icCstj||||_dS(N(RbRjt_mintime(R Ritmintime((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyRjscCs=tj|jd}||jkr9|tjd|SdS(Nis (execution time: %d ms)(t_timettimet timestampRwRoRp(R RkRlRX((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyRmscOs#|jdttj|||S(NR(RtMinTimeLoggingCursorRbR(R R R((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyRs(RRRRjRmR(((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyRvs   R|cBs&eZdZddZddZRS(s=The cursor sub-class companion to `MinTimeLoggingConnection`.cCs"tj|_tj|||S(N(RyRzR{RuR"(R R#R$((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyR"scCs"tj|_tj|||S(N(RyRzR{RuR"(R R&R$((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyR%sN(RRRRR"R%(((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyR|s t UUID_adaptercBs2eZdZdZdZdZdZRS(sAdapt Python's uuid.UUID__ type to PostgreSQL's uuid__. .. __: http://docs.python.org/library/uuid.html .. __: http://www.postgresql.org/docs/current/static/datatype-uuid.html cCs ||_dS(N(t_uuid(R tuuid((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyR scCs|tjkr|SdS(N(t_extt ISQLQuote(R tproto((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyt __conform__scCstd|jS(Ns '%s'::uuid(RR~(R ((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyt getquotedscCs d|jS(Ns '%s'::uuid(R~(R ((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyt__str__s(RRRR RRR(((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyR}s    csddl|s!d}d}n0t|ttfrE|\}}n |}d}tj|fdfdt_tj|fdtjt_tj tj|tj tj|tj jt tjS(sRCreate the UUID type and an uuid.UUID adapter. :param oids: oid for the PostgreSQL :sql:`uuid` type, or 2-items sequence with oids of the type and the array. If not specified, use PostgreSQL standard oids. :param conn_or_curs: where to register the typecaster. If not specified, register it globally. iNi i tUUIDcs|rj|pdS(N(RR(RCR(R(sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pytssUUID[]( RR,R/R7Rtnew_typeRtnew_array_typet UUIDARRAYt register_typetregister_adapterR}(toidst conn_or_curstoid1toid2((RsB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyt register_uuids  tInetcBsDeZdZdZdZdZdZdZdZRS(sCWrap a string to allow for correct SQL-quoting of inet values. Note that this adapter does NOT check the passed value to make sure it really is an inet-compatible address but DOES call adapt() on it to make sure it is impossible to execute an SQL-injection by passing an evil value to the initializer. cCs ||_dS(N(taddr(R R((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyR scCsd|jj|jfS(Ns%s(%r)(t __class__RR(R ((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyt__repr__scCs ||_dS(N(t_conn(R tconn((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pytpreparescCsEt|j}t|dr1|j|jn|jtdS(NRs::inet(t_ARRrRRRR(R tobj((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyRscCs|tjkr|SdS(N(RR(R R((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyRscCs t|jS(N(tstrR(R ((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyR s( RRRR RRRRR(((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyRs     cCs|sd}d}n0t|ttfr9|\}}n |}d}tj|fddt_tj|fdtjt_tjtj|tjtj|tjS(sLCreate the INET type and an Inet adapter. :param oid: oid for the PostgreSQL :sql:`inet` type, or 2-items sequence with oids of the type and the array. If not specified, use PostgreSQL standard oids. :param conn_or_curs: where to register the typecaster. If not specified, register it globally. ieitINETcSs|rt|pdS(N(RR(RCR((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyR!st INETARRAY( R,R/R7RRRRRR(toidRRR((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyt register_inets  cCs ddl}|jdtdS(sThe function used to register an alternate type caster for :sql:`TIMESTAMP WITH TIME ZONE` to deal with historical time zones with seconds in the UTC offset. These are now correctly handled by the default type caster, so currently the function doesn't do anything. iNt deprecated(twarningstwarntDeprecationWarning(RRR((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pytregister_tstz_w_secs*s cCsddl}ddlm}m}m}x|j}||krGPq+||krr|j|jgggq+||kr|jg|jggq+|jd|q+dS(sWait until a connection or cursor has data available. The function is an example of a wait callback to be registered with `~psycopg2.extensions.set_wait_callback()`. This function uses :py:func:`~select.select()` to wait for data available. iN(tPOLL_OKt POLL_READt POLL_WRITEsbad state from poll: %s(tselecttpsycopg2.extensionsRRRtpolltfilenotOperationalError(RRRRRtstate((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyt wait_select6s     cCsm|dkrtjdnt|drK|j}|jdt}n|}|jdt}||fS(sEReturn the connection and a DBAPI cursor from a connection or cursor.s no connection or cursor providedR"RN(Rtpsycopg2RsRrRRt_cursor(RRRl((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyt_solve_conn_cursMs  t HstoreAdaptercBseZdZdZdZdZdZeZej dej Z e ej ddZ e dZe d ZRS( s)Adapt a Python dict to the hstore syntax.cCs ||_dS(N(twrapped(R R((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyR ^scCs+||_|jdkr'|j|_ndS(Ni_(Rtserver_versiont _getquoted_8R(R R((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyRas cCs|jstdStj}g}x|jjD]\}}||}|j|j|j}|dk r||}|j|j|j}n td}|j td|td|tdq2Wtdtdj |tdS(s*Use the operators available in PG pre-9.0.s ''::hstoretNULLt(s => t)s||N( RRRRR4RRRRRLtjoin(R RtrvtkR3((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyRhs        3cCs|jstdStj|jj}|j|jtj|jj}|j|jtd|jtd|jtdS(s(Use the hstore(text[], text[]) function.s ''::hstoreshstore(s, R( RRRRR6RRR8R(R RR3((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyt _getquoted_9s  sm # hstore key: # a string of normal or escaped chars "((?: [^"\\] | \\. )*)" \s*=>\s* # hstore value (?: NULL # the value can be null - not catched # or a quoted string like the key | "((?: [^"\\] | \\. )*)" ) (?:\s*,\s*|$) # pairs separated by comma or end of string. s\\(.)c Cs|dkrdSi}d}x|jj|D]}|dksS|j|kritjd|n|jd|jd}|jd}|dk r|jd|}n|||<|j}q/W|t |krtjd|n|S(sParse an hstore representation in a Python string. The hstore is represented as something like:: "a"=>"1", "b"=>"2" with backslash-escaped strings. is$error parsing hstore pair at char %ds\1iis1error parsing hstore: unparsed data after char %dN( Rt _re_hstoretfinditertstartRtInterfaceErrortsubtgrouptendR)( R tstcurt_bsdecRRtmRR3((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pytparses$   cCs<|dkrdS|jtj|jj}|j||S(s2Parse an hstore returning unicode keys and values.N(RtdecodeRt encodingsRtencodingR(R RR((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyt parse_unicodes c Cst|\}}|j}|jdkr0dp3d}gg}}|jd|x0|D](}|j|d|j|dq[W|tjkr|j r|jnt |t |fS(sBReturn the lists of OID of the hstore and hstore[] types. i9ttyparrayRslSELECT t.oid, %s FROM pg_type t JOIN pg_namespace ns ON typnamespace = ns.oid WHERE typname = 'hstore'; ii( RtstatusRR"RLRtSTATUS_IN_TRANSACTIONt autocommittrollbackR7( R RRRlt conn_statusRtrv0trv1R((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pytget_oidss      (RRRR RRRRt_retcompiletVERBOSERt classmethodRRR(((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyR\s       c Cst|dkr[tj|}|dks2|d rDtjdq[|d}|d}nt|trv|f}n|dk rt|tr|f}qtg|D]}|r|^q}ntj ddkr|rtj }n tj }t j |d|}t j|| r|p!dt jtt|rpt j|d|}t j|| rf|pidndS(sRegister adapter and typecaster for `!dict`\-\ |hstore| conversions. :param conn_or_curs: a connection or cursor: the typecaster will be registered only on this object unless *globally* is set to `!True` :param globally: register the adapter globally, not only on *conn_or_curs* :param unicode: if `!True`, keys and values returned from the database will be `!unicode` instead of `!str`. The option is not available on Python 3 :param oid: the OID of the |hstore| type if known. If not, it will be queried on *conn_or_curs*. :param array_oid: the OID of the |hstore| array type if known. If not, it will be queried on *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 |hstore| type (which may be different across databases). If querying is not desirable (e.g. with :ref:`asynchronous connections `) you may specify it in the *oid* parameter, which can be found using a query such as :sql:`SELECT 'hstore'::regtype::oid`. Analogously you can obtain a value for *array_oid* using a query such as :sql:`SELECT 'hstore[]'::regtype::oid`. Note that, when passing a dictionary from Python to the database, both strings and unicode keys and values are supported. Dictionaries returned from the database have keys/values according to the *unicode* parameter. The |hstore| contrib module must be already installed in the database (executing the ``hstore.sql`` script in your ``contrib`` directory). Raise `~psycopg2.ProgrammingError` if the type is not found. is\hstore type not found in the database. please install it from your 'contrib/hstore.sql' fileiitHSTOREt HSTOREARRAYN(RRRRRsR,R-R7RFRGRRRRRRR?R( RtgloballytunicodeRt array_oidR1tcastRR((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pytregister_hstores,       (  tCompositeCastercBszeZdZd d dZdZdZejdej Z ejdZ e dZ dZe dZRS( smHelps conversion of a PostgreSQL composite type into a Python object. The class is usually created by the `register_composite()` function. You may want to create and register manually instances of the class if querying the database at registration time is not desirable (such as when using an :ref:`asynchronous connections `). cCs||_||_||_||_g|D]}|d^q+|_g|D]}|d^qK|_|j||jtj|f||j |_ |rtj |fd||j |_ n d|_ dS(Niis%sARRAY(ROtschemaRRtattnamestatttypest _create_typeRRRt typecasterRtarray_typecasterR(R RORtattrsRRta((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyR .s      cCs|dkrdS|j|}t|t|jkrktjdt|j|jt|fngt|j|D]\}}|j||^q~}|j |S(Ns9expecting %d components for the type %s, %d found instead( RttokenizeR)RRt DataErrorROtzipRtmake(R RRlttokensRttokenR8((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyR>s (4cCs |j|S(sReturn a new Python object representing the data being casted. *values* is the list of attributes, already casted into their Python representation. You can subclass this method to :ref:`customize the composite cast `. (t_ctor(R R8((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyRMs s \(? ([,)]) # an empty token, representing NULL | \(? " ((?: [^"] | "")*) " [,)] # or a quoted string | \(? ([^",)]+) [,)] # or an unquoted string s (["\\])\1cCsg}x|jj|D]}|dkrAtjd|n|jddk rf|jdq|jddk r|j|jjd|jdq|j|jdqW|S(Nscan't parse type: %riis\1i( t _re_tokenizeRRRRRRLt _re_undoubleR(R RRR((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyRas (cCsbyddlm}Wn&tk r<t|_|j|_n"X||||_|jj|_dS(Ni(R](R`R]RaR7RNRRW(R RORR]((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyRps  c Cs0t|\}}|j}d|krB|jdd\}}n |}d}|jdkrcdpfd}|jd|||f|j} |tjkr|j r|j n| st j d|n| d d } | d d} g| D]} | d | d f^q} ||| | d | d |S(s}Return a `CompositeCaster` instance for the type *name*. Raise `ProgrammingError` if the type is not found. t.itpublici9RRsSELECT t.oid, %s, attname, atttypid FROM pg_type t JOIN pg_namespace ns ON typnamespace = ns.oid JOIN pg_attribute a ON attrelid = typrelid WHERE typname = %%s AND nspname = %%s AND attnum > 0 AND NOT attisdropped ORDER BY attnum; sPostgreSQL type '%s' not foundiiiRR( RRtsplitRR"RRRRRRRs(R RORRRlRRttnameRtrecsttype_oidRtrt type_attrs((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyt_from_dbzs*     'N(RRRRR RRRRRRRRRRR(((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pyR%s   cCs}|dkrt}n|j||}tj|j| r@|pCd|jdk rytj|j| ro|prdn|S(sRegister a typecaster to convert a composite type into a tuple. :param name: the name of a PostgreSQL composite type, e.g. created using the |CREATE TYPE|_ command :param conn_or_curs: a connection or cursor used to find the type oid and components; the typecaster is registered in a scope limited to this object, unless *globally* is set to `!True` :param globally: if `!False` (default) register the typecaster only on *conn_or_curs*, otherwise register it globally :param factory: if specified it should be a `CompositeCaster` subclass: use it to :ref:`customize how to cast composite types ` :return: the registered `CompositeCaster` or *factory* instance responsible for the conversion N(RRRRRRR(RORRtfactorytcaster((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pytregister_composites   #(tjsontJsont register_json(tregister_default_jsontregister_default_jsonb(tRanget NumericRange(t DateRanget DateTimeRangetDateTimeTZRange(tregister_ranget RangeAdaptert RangeCaster(BRtosRotsysRFRzRytreRtloggingRdRRRRRRRRt _connectionRRRRRRR/R RHRIR?RJRRRSRbRuRvR|tobjectR}RRRRRRRtFalseRRRtpsycopg2._jsonRRRRRtpsycopg2._rangeRRRRRR R R (((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/extras.pytsX      9DK-"  @