ploneasgi.settings#

Environment-only configuration, replacing the PasteDeploy .ini.

ploneasgi.settings.LOG_FORMAT = '%(asctime)s %(levelname)-7.7s [%(name)s:%(lineno)s][%(threadName)s] %(message)s'#

Mirrors formatter_generic from the generated zope.ini, so log output stays recognizable after dropping PasteDeploy.

ploneasgi.settings.load_env(path=None)[source]#

Load a .env file, if present.

Must be called before any Zope import or configuration read. load_dotenv does not override variables already in the environment, so a container's real environment always wins over a local file.

Parameters:

path (Path | str | None) -- Path to the .env file; defaults to .env in the cwd.

Return type:

None

ploneasgi.settings.flag(name, default='')[source]#

Read a boolean toggle from the environment.

Parameters:
  • name (str) -- Environment variable name.

  • default (str) -- Value assumed when the variable is unset.

Returns:

True when the value is one of 1, true, on, yes.

Return type:

bool

class ploneasgi.settings.Settings[source]#

Runtime configuration for an ASGI-hosted Plone.

Built from the environment by from_env() rather than from class-level defaults, so tests can construct an explicit instance without touching os.environ.

host: str#

Interface to bind. 0.0.0.0 is IPv4-only under uvicorn, unlike waitress's localhost, which also binds IPv6.

concurrency: int#

Concurrent WSGI calls. Must not exceed the ZODB pool-size or requests block waiting for a database connection.

chunk_size: int#

Bytes pulled per thread hop when streaming a response body.

route_prefix: str#

Path prefix reserved for native ASGI routes. Every ZCML-registered route lives under it, which is what lets a deployment keep one proxy rule.

site_id: str#

Site entered by native routes when a request arrives with no VirtualHostMonster rewrite — direct access, i.e. development. Behind a proxy the rewrite is authoritative and this is unused.

max_body_size: int#

Largest request body accepted, in bytes; larger ones get a 413 before Zope runs. waitress's default. 0 disables the limit.

classmethod from_env(base=None)[source]#

Build settings from environment variables.

Parameters:

base (Path | None) -- Directory that relative default paths resolve against.

Returns:

A populated Settings instance.

Return type:

Settings

__init__(host='0.0.0.0', port=8080, concurrency=4, access_log=False, log_level='INFO', zope_conf=<factory>, chunk_size=262144, route_prefix='/++asgi++', site_id='Plone', max_body_size=1073741824)#
Parameters:
  • host (str)

  • port (int)

  • concurrency (int)

  • access_log (bool)

  • log_level (str)

  • zope_conf (Path)

  • chunk_size (int)

  • route_prefix (str)

  • site_id (str)

  • max_body_size (int)

Return type:

None

ploneasgi.settings.setup_logging(settings)[source]#

Configure logging for the no-ini case.

runwsgi normally hands the PasteDeploy .ini to logging.config.fileConfig(), which is where Zope's event log and access log get configured. Dropping the ini drops that too, so configure a plain stream handler instead and let the container collect stdout.

Uses force=True because Zope's startup installs its own handlers: without it, basicConfig silently does nothing whenever this is called after ploneasgi.zopeapp.build_wsgi_app(), and the access log emits nothing at all. That ordering is easy to hit — it is what a project's server.py does when it builds the WSGI app itself to collect ZCML routes.

Parameters:

settings (Settings) -- Settings providing the desired log level.

Return type:

None