profile

This module is used to store/retrieve user profiles on the local machine. A user profile can contain information such as connection parameters to the database or the language the user wants to use in the application.

For this module to function correctly, the settings should have an attribute named CAMELOT_DBPROFILES_CIPHER. This is a ‘secret’ per application string that is used to encrypt the profile information as it is stored on the local machine.

class camelot.core.profile.Profile(name, **kwargs)[source]

This class holds the local configuration of the application, such as the location of the database. It provides some convenience functions to store and retrieve this information to QtCore.QSettings

Parameters:name – the name of the profile

The Profile class has ordering methods based on the name of the profile object.

create_engine(**kwargs)[source]

create a SQLAlchemy Engine from the selected profile, all arguments are passed to the create_engine function.

get_connection_string()[source]

The database connection string according to SQLAlchemy conventions, as specified by this profile.

get_country_code()[source]
Returns:two-letter ISO 3166 country code
get_language_code()[source]
Returns:two-letter ISO 639 language code
class camelot.core.profile.ProfileStore(filename=None, profile_class=<class 'camelot.core.profile.Profile'>, cipher_key=None)[source]

Class that reads/writes profiles, either to a file or to the local application settings.

Parameters:
  • filename – the name of the file to read/write profiles from, if left to None, the application settings are used.
  • profile_class – a serializeable class that can be used to create new profile objects.
  • cipher_key – cipher key used to encrypt profile information to make it only readeable to the application itself. If left to None, `camelot.core.conf.settings.CAMELOT_DBPROFILES_CIPHER is used.
get_last_profile()[source]
Returns:the last used profile, or None of no profile has been used yet or the profile information is not available.
read_profile(name)[source]
Returns:the profile object with the requested name, None if there is no such profile
read_profiles()[source]
Returns:a list of profiles read
set_last_profile(profile)[source]
Parameters:profile – a profile that has been written to or is available in the store
write_profile(profile)[source]
Parameters:profile – a Profile object
write_profiles(profiles)[source]
Parameters:profiles – a list of profiles