citric.session
#
Low level wrapper for connecting to the LSRC2.
Module Contents#
Classes#
LimeSurvey RemoteControl 2 session. |
- class citric.session.Session(url, username, password, *, auth_plugin='Authdb', requests_session=None, json_encoder=None)[source]#
LimeSurvey RemoteControl 2 session.
Upon creation, retrieves a session key with get_session_key and stores it in the key attribute. The key is released upon session closure.
- Parameters:
url (str) – LimeSurvey Remote Control endpoint.
username (str) – LimeSurvey user name.
password (str) – LimeSurvey password.
requests_session (requests.Session | None) – A requests.Session object.
auth_plugin (str) – Name of the plugin to use for authentication. For example, AuthLDAP. Defaults to using the internal database (
"Authdb"
).json_encoder (type[json.JSONEncoder] | None) – A JSON encoder class <JSONEncoder> to use for encoding RPC parameters.
Changed in version 0.0.4: Replaced the
requests_session_factory
parameter withrequests_session
.New in version 0.0.6: Support Auth plugins with the
auth_plugin
parameter.New in version 0.5.0: The
json_encoder
parameter.- rpc(method, *params)[source]#
Execute RPC method on LimeSurvey, with optional token authentication.
Any method, except for get_session_key.
- Parameters:
method (str) – Name of the method to call.
params (Any) – Positional arguments of the RPC method.
- Returns:
An RPC result.
- Return type:
citric.types.Result
- _invoke(method, *params)[source]#
Execute a LimeSurvey RPC with a JSON payload.
- Parameters:
method (str) – Name of the method to call.
params (Any) – Positional arguments of the RPC method.
- Raises:
ResponseMismatchError – Request ID does not match the response ID.
RPCInterfaceNotEnabledError – If the JSON RPC interface is not enabled (empty response).
InvalidJSONResponseError – If the response is not valid JSON.
- Returns:
An RPC result.
- Return type:
citric.types.Result
- close()[source]#
Close RPC session.
Releases the session key with release_session_key.