Hacker News new | ask | show | jobs
by musingsole 1080 days ago
The Handlers implement behavior, sure. But from the perspective of the `app` object, the handler function objects are state. You can tell, because `app` is an instance of the Flask class and the Handlers are added to the instance by way of a function call.

So, Handlers are functions that "handle something", but they are also part of the app object's state, not its behavior.

2 comments

By that definition an app could never be stateless ?
That's a very oversimplified view of handlers.

An alternate view might be:

Handlers are functions that are part of the app object's state, which alters the app's behavior.

In the majority (possibly overwhelming majority) of the cases this is true. The purpose of Handlers and similar Publisher/Subscriber patterns is effectively to change application behavior when they are configured.

> Handlers are functions that are part of the app object's state, which alters the app's behavior.

I find that phrasing very fair.