Models

class composapy.key.models.KeyObject(contract)

KeyObject is a wrapper with a custom load strategy for the Composable Property contract. The key attributes are dynamically constructed based on key type retrieved.

from composapy.key.api import Key

key_object = Key.get(123456)
print(key_object)
# Key(name='us3r db connection key', type='SqlConnectionSettings')
print(key_object.__dict__)
# {'contract': <CompAnalytics.Contracts.Property object at 0x000001CE10E18A40>,
#  'Password': 'pa55w0rd',
#  'ConnectionParameters': [],
#  'Database': 'TestDb',
#  'Host': '.',
#  'Port': None,
#  'UseMultipleActiveResultSets': None,
#  'Username': 'us3r'}

key_object = Key.get(654321)
print(key_object)
# Key(name='us3r login credentials', type='Credential')
print(key_object.__dict__)
# {'contract': <CompAnalytics.Contracts.Property object at 0x000001CE65B37300>,
#  'Password': 'pa55w0rd',
#  'UserName': 'Us3rNam3'}
classmethod clear_registration() None

Used to unregister the currently registered KeyObject.

KeyObject.clear_registration()
property id: int

Returns the contract member, Id.

property name: str

Returns the contract member, Name.

register(save=False) None

Used to register a class instance of KeyObject that is used implicitly across the kernel. Only one KeyObject can registered at a time.

key_object = KeyObject(123456)
key_object.register(save=True)
Parameters:

save – If true, saves configuration in local composapy.ini file. Default is false.

property type: str

Returns the contract member, DisplayType.

exception composapy.key.models.KeyObjectException
exception composapy.key.models.KeyObjectRegistrationException
composapy.key.models.get_key_object(raise_exception=True) KeyObject | None

Used to get the current registered KeyObject.

from composapy.key.api import get_key_object
KeyObject(123456).register()
key_object = get_key_object()  # can use this anywhere on running kernel
Returns:

the currently registered key object