Settings
- Threads
- Routing
- Templating
- Static Files
- Client
- Sessions
- Views
- Error Views
- Channels
- Buckets
- Middlewares
- Shell
- Testing
- Server
- Feature Flags
Settings can be live analyzed by using the Lona Shell command %lona_settings.
Threads
MAX_WORKER_THREADS =
4
MAX_STATIC_THREADS =
4
MAX_RUNTIME_THREADS =
6
MAX_CHANNEL_MESSAGE_BROKER_THREADS =
1
MAX_CHANNEL_TASK_WORKER_THREADS =
4
Routing
ROUTING_TABLE =
'lona.default_routes.routes'
ROUTING_RESOLVE_CACHE_MAX_SIZE =
1000
Lona uses a functools.lru_cache to cache resolving requests. This setting configures the max size of this cache.
ROUTING_REVERSE_CACHE_MAX_SIZE =
1000
Lona uses a functools.lru_cache to cache reverse resolving requests. This setting configures the max size of this cache.
Templating
TEMPLATE_DIRS =
[]
FRONTEND_TEMPLATE =
'lona/frontend.html'
ERROR_403_TEMPLATE =
'lona/403.html'
ERROR_404_TEMPLATE =
'lona/404.html'
ERROR_500_TEMPLATE =
'lona/500.html'
TEMPLATE_EXTRA_CONTEXT =
{}
TEMPLATE_EXTRA_FILTERS =
{}
Note
Added in 1.8.4
All filters defined in this dictionary will be added to the Jinja2 templating environment.
More Information: Custom Jinja2 Filters
Static Files
STATIC_DIRS =
[]
STATIC_URL_PREFIX =
'/static/'
STATIC_FILES_SERVE =
True
STATIC_FILES_STYLE_TAGS_TEMPLATE =
'lona/style_tags.html'
STATIC_FILES_SCRIPT_TAGS_TEMPLATE =
'lona/script_tags.html'
STATIC_FILES_ENABLED =
[]
STATIC_FILES_DISABLED =
[]
Client
CLIENT_DEBUG =
False
CLIENT_AUTO_RECONNECT =
True
Note
Added in 1.16
When set to True the client will try to reconnect to the server periodically when the websocket connection closes
CLIENT_AUTO_RECONNECT_TIMEOUT =
1000
Note
Added in 1.16
Auto reconnect timeout in ms
CLIENT_VIEW_START_TIMEOUT =
2
CLIENT_INPUT_EVENT_TIMEOUT =
2
CLIENT_PING_INTERVAL =
60
Note
Added in 1.7.4
To disable ping messages set to 0.
Sessions
SESSIONS =
True
SESSIONS_KEY_GENERATOR =
'lona.middlewares.sessions.generate_session_key'
SESSIONS_KEY_NAME =
'sessionid'
SESSIONS_KEY_RANDOM_LENGTH =
28
SESSIONS_REUSE =
True
When set to False, the session middleware will generate a random session key for every new connection regardless of a session cookie is set or not.
This is helpful for testing multi-user views because it gives all browser tabs their own session.
Views
FRONTEND_VIEW =
''
INITIAL_SERVER_STATE =
{}
Note
Added in 1.10.1
This dict, if present, is copied to server.state. This is a convenient way to define or load server state on startup without the need to write a specific middleware.
Channels
CHANNEL_WORKER_TIMEOUT =
1.0
CHANNEL_MESSAGE_BROKER_CLASS =
'lona.channels.MessageBroker'
CHANNEL_TASK_WORKER_CLASS =
'lona.channels.TaskWorker'
Server
AIOHTTP_CLIENT_MAX_SIZE =
1048576
Note
Added in 1.10.2
This value is used to set the client_max_size value for the aiohttp server. It defines the maximum body size of a post request accepted by the server. See aiohttp documentation for details. The default value is set to the aiohttp default of 1024**2 Bytes.
Feature Flags
STOP_DAEMON_WHEN_VIEW_FINISHES =
True
Note
Added in 1.11
Default for LonaView.STOP_DAEMON_WHEN_VIEW_FINISHES.
See LonaView.is_daemon for details.
CLIENT_VERSION =
1
Note
Added in 1.12
Lona 2.0 will have a new JavaScript client implementation. The new client can be used, in compatible Lona 1 projects, by setting this value to 2.
The currently set client version can be checked, using lona.compat.get_client_version(), and in the frontend using Lona.client_version.
When the new client gets used:
All HTML components have to have exactly one root node (Widgets supported multiple root nodes until Lona 2)
lona.html.Widget objects are no longer supported, and can not be rendered in the browser
lona.html.HTML no longer returns a widget but exactly one lona.html.AbstractNode.
When lona.html.HTML gets initialized with multiple nodes, or the parsing result contains multiple nodes on the first level, lona.html.HTML wraps all nodes into one div node
USE_FUTURE_NODE_CLASSES =
False
Note
Added in 1.12
Some node classes from the standard library will be replaced, in Lona 2, by their newer counter-parts. All new node classes can be used immediately, but when parsing HTML strings, using lon.html.HTML, the old node classes get used, for compatibility reasons.
When settings.USE_FUTURE_NODE_CLASSES is set to True:
- lona.html.Select2 gets used instead of lona.html.Select