Copyright (C) 2012, University of Cambridge, Department of Psychiatry. Created by Rudolf Cardinal (firstname.lastname@example.org).
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)¶
Represents session information for client devices. They use HTTPS POST calls and do not bother with cookies.
- __init__(req: CamcopsRequest) None ¶
- 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]¶
camcops_server.cc_modules.cc_device.Deviceassociated with this request/session, or
- property device_id: Optional[int]¶
Returns the integer device ID, if known.
- ensure_device_registered() None ¶
Ensure the device is registered. Raises
- ensure_valid_device_and_user_for_uploading() None ¶
Ensure the device/username/password combination is valid for uploading. Raises
- ensure_valid_user_for_device_registration() None ¶
Ensure the username/password combination is valid for device registration. Raises
- property explicit_pkname_for_upload_table: bool¶
Is the client a nice new one that explicitly names the primary key when uploading tables?
- is_device_registered() bool ¶
Is the device registered with our server?
- 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.
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 ¶
Sets the session ID and token. Typical situation:
camcops_server.cc_modules.cc_tabletsession.TabletSessioncreated; may or may not have an ID/token as part of the POST request
camcops_server.cc_modules.cc_request.CamcopsRequesttranslates that into a server-side session
If 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.