Changeset 803 for trunk/docs


Ignore:
Timestamp:
Jan 31, 2016, 4:39:40 PM (3 years ago)
Author:
cito
Message:

Add documentation for get/set_cast_hook

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/docs/contents/pg/module.rst

    r802 r803  
    309309which does exactly the same.
    310310
     311get/set_namedresult -- conversion to named tuples
     312-------------------------------------------------
     313
     314.. function:: get_namedresult()
     315
     316    Get the function that converts to named tuples
     317
     318This returns the function used by PyGreSQL to construct the result of the
     319:meth:`Query.namedresult` method.
     320
     321.. versionadded:: 4.1
     322
     323.. function:: set_namedresult(func)
     324
     325    Set a function that will convert to named tuples
     326
     327    :param func: the function to be used to convert results to named tuples
     328
     329You can use this if you want to create different kinds of named tuples
     330returned by the :meth:`Query.namedresult` method.  If you set this function
     331to *None*, then it will become equal to :meth:`Query.getresult`.
     332
     333.. versionadded:: 4.1
     334
    311335get/set_decimal -- decimal type to be used for numeric values
    312336-------------------------------------------------------------
     
    347371PostgreSQL monetary values when converting them to decimal numbers.
    348372The default setting is ``'.'`` as a decimal point. This setting is not
    349 adapted automatically to the locale used by PostGreSQL, but you can
    350 use ``set_decimal()`` to set a different decimal mark manually. A return
     373adapted automatically to the locale used by PostGreSQL, but you can use
     374:func:`set_decimal()` to set a different decimal mark manually. A return
    351375value of ``None`` means monetary values are not interpreted as decimal
    352376numbers, but returned as strings including the formatting and currency.
     
    387411strings which are the values used internally by PostgreSQL. By default,
    388412conversion to bool objects is not activated, but you can enable
    389 this with the ``set_bool()`` method.
     413this with the :func:`set_bool` function.
    390414
    391415.. versionadded:: 4.2
     
    405429.. versionadded:: 4.2
    406430
    407 get/set_bytea_escaped -- whether bytea values are returned escaped
    408 ------------------------------------------------------------------
     431get/set_bytea_escaped -- whether bytea data is returned escaped
     432---------------------------------------------------------------
    409433
    410434.. function:: get_bytea_escaped()
     
    418442escaped form or in unescaped from as byte strings.  By default, bytea values
    419443will be returned unescaped as byte strings, but you can change this with the
    420 ``set_bytea_escaped()`` method.
     444:func:`set_bytea_escaped` function.
    421445
    422446.. versionadded:: 5.0
     
    436460
    437461.. versionchanged:: 5.0
    438    Bytea values had been returned in escaped form in earlier versions.
    439 
    440 get/set_namedresult -- conversion to named tuples
    441 -------------------------------------------------
    442 
    443 .. function:: get_namedresult()
    444 
    445     Get the function that converts to named tuples
    446 
    447 This returns the function used by PyGreSQL to construct the result of the
    448 :meth:`Query.namedresult` method.
    449 
    450 .. versionadded:: 4.1
    451 
    452 .. function:: set_namedresult(func)
    453 
    454     Set a function that will convert to named tuples
    455 
    456     :param func: the function to be used to convert results to named tuples
    457 
    458 You can use this if you want to create different kinds of named tuples
    459 returned by the :meth:`Query.namedresult` method.  If you set this function
    460 to *None*, then it will become equal to :meth:`Query.getresult`.
    461 
    462 .. versionadded:: 4.1
     462   Bytea data had been returned in escaped form in earlier versions.
    463463
    464464get/set_jsondecode -- decoding JSON format
     
    480480You can use this if you do not want to deserialize JSON strings coming
    481481in from the database, or if want to use a different function than the
    482 standard function :meth:`json.loads` or if you want to use it with parameters
     482standard function :func:`json.loads` or if you want to use it with parameters
    483483different from the default ones.  If you set this function to *None*, then
    484484the automatic deserialization of JSON strings will be deactivated.
     485
     486.. versionadded:: 5.0
     487
     488.. versionchanged:: 5.0
     489   JSON data had been returned in as text strings in earlier versions.
     490
     491get/set_cast_hook -- fallback typecast function
     492-----------------------------------------------
     493
     494.. function:: get_cast_hook()
     495
     496    Get the function that handles all external typecasting
     497
     498This returns the callback function used by PyGreSQL to provide plug-in
     499Python typecast functions.
     500
     501.. function:: set_cast_hook(func)
     502
     503    Set a function that will handle all external typecasting
     504
     505    :param func: the function to be used as a callback
     506
     507If you set this function to *None*, then only the typecast functions
     508implemented in the C extension module are enabled.  You normally would
     509not want to change this.  Instead, you can use :func:`get_typecast` and
     510:func:`set_typecast` to add or change the plug-in Python typecast functions.
    485511
    486512.. versionadded:: 5.0
Note: See TracChangeset for help on using the changeset viewer.