9. Modules logon and logoff

logon and logoff modules handle the moments of logging on (authorization) and off (session termination), so that you can implement your custom actions there.

For example, you can launch a timer on logon which re-checks every few minutes if there are upcoming tasks for the user and notify them if they are. Or, for instance, you can check on logoff if the user has posted a report, and if not - prevent him/her from logging off offering to make a report instead.

The logon module contains the logon() function, which handles logon (authorisation) to the application.

logon.logon()[source]

Called on logon to Cerebro, right after authorisation, and on Python being restarted on debugging.

logon.py:

def logon():
    ...

The logoff module contains the logoff() function which handles exit (log off) from the application.

logoff.logoff()[source]

Called on Cerebro session termination, returns either True or False. If the function returns True, the session terminates, otherwise the session remains active and the application does not shut down.

logoff.py:

def logoff():   
        ...
        return True # If the finction returns True, the session terminates,
                                        # otherwise the session remains active
                                        # and the application does not shut down.

The samples of event handling can be found here.