14.2.100. camcops_server.cc_modules.cc_tabletsession


Copyright (C) 2012-2019 Rudolf Cardinal (rudolf@pobox.com).

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 <http://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.


Must we cope with an old client that had ID descriptors in the Patient table?


Must we cope with an old client that had ID numbers embedded in the Patient table?


Returns the camcops_server.cc_modules.cc_device.Device associated with this request/session, or None.


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.


Is the client a nice new one that explicitly names the primary key when uploading tables?

is_device_registered() → bool[source]

Is the device registered with our server?


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[source]

Sets the session ID and token. Typical situation:


Returns the integer user ID, if known.