15.2.157. camcops_server.cc_modules.cc_tabletsession¶
camcops_server/cc_modules/cc_tabletsession.py
Copyright (C) 2012, University of Cambridge, Department of Psychiatry. Created by Rudolf Cardinal (rnc1001@cam.ac.uk).
This file is part of CamCOPS.
CamCOPS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
CamCOPS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with CamCOPS. If not, see <https://www.gnu.org/licenses/>.
Session information for client devices (tablets etc.).
- class camcops_server.cc_modules.cc_tabletsession.TabletSession(req: CamcopsRequest)[source]¶
Represents session information for client devices. They use HTTPS POST calls and do not bother with cookies.
- property cope_with_deleted_patient_descriptors: bool¶
Must we cope with an old client that had ID descriptors in the Patient table?
- property cope_with_old_idnums: bool¶
Must we cope with an old client that had ID numbers embedded in the Patient table?
- property device: Optional[camcops_server.cc_modules.cc_device.Device]¶
Returns the
camcops_server.cc_modules.cc_device.Device
associated with this request/session, orNone
.
- property device_id: Optional[int]¶
Returns the integer device ID, if known.
- ensure_device_registered() None [source]¶
Ensure the device is registered. Raises
UserErrorException
on failure.
- ensure_valid_device_and_user_for_uploading() None [source]¶
Ensure the device/username/password combination is valid for uploading. Raises
UserErrorException
on failure.
- ensure_valid_user_for_device_registration() None [source]¶
Ensure the username/password combination is valid for device registration. Raises
UserErrorException
on failure.
- property explicit_pkname_for_upload_table: bool¶
Is the client a nice new one that explicitly names the primary key when uploading tables?
- property pkname_in_upload_table_neither_first_nor_explicit¶
Is the client a particularly tricky old version that is a C++ client (generally a good thing, but meaning that the primary key might not be the first field in uploaded tables) but had a bug such that it did not explicitly name its PK either?
See discussion of bug in
NetworkManager::sendTableWhole
(C++). For these versions, the only safe thing is to take"id"
as the name of the (client-side) primary key.
- reload_device()[source]¶
Re-fetch the device information from the database. (Or, at least, do so when it’s next required.)
- set_session_id_token(session_id: int, session_token: str) None [source]¶
Sets the session ID and token. Typical situation:
camcops_server.cc_modules.cc_tabletsession.TabletSession
created; may or may not have an ID/token as part of the POST requestcamcops_server.cc_modules.cc_request.CamcopsRequest
translates that into a server-side sessionIf one wasn’t found and needs to be created, we write back the values here.
- property user_id: Optional[int]¶
Returns the integer user ID, if known.