6.1.1.3.2.21. linotp.lib.reply module

create responses

linotp.lib.reply.create_html(data, width=0, alt=None)[source]

_create_html - create the qr image data embeded in html tag

Parameters:
  • data (string) – input data that will be munched into the qrcode
  • width (int) – image width in pixel
Returns:

<img/> taged data

Return type:

string

linotp.lib.reply.create_img(data, width=0, alt=None)[source]

_create_img - create the qr image data

Parameters:
  • data (string) – input data that will be munched into the qrcode
  • width (int) – image width in pixel
Returns:

<img/> taged data

Return type:

string

linotp.lib.reply.create_png(data, alt=None)[source]
linotp.lib.reply.sendCSVResult(response, obj, flat_lines=False, filename='linotp-tokendata.csv')[source]

returns a CSV document of the input data (like in /admin/show)

Parameters:
  • response – The pylons response object
  • obj (JSON object) – The data, that gets serialized as CSV
  • flat_lines – If True the object only contains a list of the dict { ‘cell’: ..., ‘id’: ... } as in all the flexigrid functions.

‘type flat_lines: boolean

linotp.lib.reply.sendError(response, exception, id=1, context=None)[source]

sendError - return a json error result document

remark:
the ‘context’ is especially required to catch errors from the _before_ methods. The return of a _before_ must be of type response and must have the attribute response._exception set, to stop further processing, which otherwise will have ugly results!!
Parameters:
  • response (response object) – the pylon response object
  • exception (exception) – should be a linotp exception (s. linotp.lib.error.py)
  • id (int) – id value, for future versions
  • context (string) – default is None or ‘before’
Returns:

json rendered sting result

Return type:

string

linotp.lib.reply.sendQRImageResult(response, data, param=None, id=1, typ='html')[source]
method
sendQRImageResult
arguments
response - the pylon response object param - the paramters of the request id - html - print qrcode wrapped by html or not
linotp.lib.reply.sendResult(response, obj, id=1, opt=None)[source]

sendResult - return an json result document

Parameters:
  • response (response object) – the pylons response object
  • obj (dict or list or string/unicode) – simple result object like dict, sting or list
  • id (int) – id value, for future versions
  • opt (None or simple type like dict, list or string/unicode) – optional parameter, which allows to provide more detail
Returns:

json rendered sting result

Return type:

string

linotp.lib.reply.sendXMLError(response, exception, id=1)[source]
linotp.lib.reply.sendXMLResult(response, obj, id=1)[source]