Handlers¶
The handler concept is central to the app architecture.
A handler is just a Python class, responsible for some portion of the overall app. For instance the auth handler will check user login credentials, and the email handler will generate and send messages.
There is a special app handler which is effectively the “root” handler and is responsible for instantiating all other handlers (among other things).
As a general rule, there is only one handler configured for a given aspect (e.g. auth, email) - although multiple may be installed.
Calling code therefore should not instantiate a particular handler class, but rather ask the app handler to do it. This allows for config auto-lookup and more readable code:
app = config.get_app()
auth = app.get_auth_handler()
with app.short_session() as session:
user = auth.authenticate_user(session, "myuser", "mypass")
email = app.get_email_handler()
email.send_email("foo", {"bar": "baz"})
Wutta Framework has several built-in handler types, but custom types can also be defined.