Skip to content

Get respo model

Load generated model in Python code

In previous section, we created .respo_cache folder and respo_model.py file for better autocompletion.

To load your respo model in the app and pass it around, you can now use following code, typically you should put it in file like main.py, settings.py, config.py or similar:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# main.py

from .respo_model import RespoModel

RESPO_MODEL = RespoModel.get_respo_model()

print(RESPO_MODEL.ROLES)
# {'default': ['user.read_basic'], 'admin': ['user.read_all', 'user.read_basic']}

print(RESPO_MODEL.ROLES.DEFAULT)
# default

print("test_role" in RESPO_MODEL.PERMS)
# False

We will be using it in next sections.