org.app
Contains the base application used by other applications.
Classes
Baseclass for Morepath OneGov applications. |
|
Functions
Module Contents
- class org.app.OrgApp[source]
Bases:
onegov.core.Framework
,onegov.reservation.LibresIntegration
,onegov.search.ElasticsearchApp
,onegov.gis.MapboxApp
,onegov.file.DepotApp
,onegov.pay.PayApp
,onegov.form.FormApp
,onegov.user.UserApp
,onegov.websockets.WebsocketsApp
Baseclass for Morepath OneGov applications.
- serve_static_files = True[source]
Returns True if
/static
files should be served. Needs to be enabled manually.Note that even if the static files are not served,
/static
path is still served, it just won’t return anything but a 404.Note also that static files are served publicly. You can override this in your application, but doing that and testing for it is on you!
See also:
onegov.core.static
.
- request_class[source]
The class of the Request to create. Must be a subclass of
morepath.Request
.By default the request class is
morepath.Request
- is_allowed_application_id(application_id: str) bool [source]
Stops onegov.server from ever passing the request to the org application, if the schema does not exist. This way we can host onegov.org in a way that allows all requests to
*.example.org
.If the schema for
newyork.example.org
exists, the request is handled. If the schema does not exist, the request is not handled.Here we basically decide if an org exists or not.
- configure_application(**cfg: Any) None [source]
Configures the application. This function calls all methods on the current class which start with
configure_
, passing the configuration as keyword arguments.The core itself supports the following parameters. Additional parameters are made available by extra
configure_
methods.- Dsn:
The database connection to use. May be None.
See
onegov.core.orm.session_manager.setup()
- Base:
The declarative base class used. By default,
onegov.core.orm.Base
is used.- Identity_secure:
True if the identity cookie is only transmitted over https. Only set this to False during development!
- Identity_secret:
A random string used to sign the identity. By default a random string is generated. The drawback of this is the fact that users will be logged out every time the application restarts.
So provide your own if you don’t want that, but be sure to have a really long, really random key that you will never share with anyone!
- Redis_url:
The redis url used (default is ‘redis://localhost:6379/0’).
- File_storage:
The file_storage module to use. See https://docs.pyfilesystem.org/en/latest/filesystems.html
- File_storage_options:
A dictionary of options passed to the
__init__
method of the file_storage class.The file storage is expected to work as is. For example, if
fs.osfs.OSFS
is used, the root_path is expected exist.The file storage can be shared between different onegov.core applications. Each application automatically gets its own namespace inside this space.
- Always_compile_theme:
If true, the theme is always compiled - no caching is employed.
- Allow_shift_f5_comple:
If true, the theme is recompiled if shift+f5 is done on the browser (or shift + reload button click).
- Csrf_secret:
A random string used to sign the csrf token. Make sure this differs from
identity_secret
! The algorithms behind identity_secret and the csrf protection differ. If the same secret is used we might leak information about said secret.By default a random string is generated. The drawback of this is the fact that users won’t be able to submit their forms if the app is restarted in the background.
So provide your own, but be sure to have a really long, really random string that you will never share with anyone!
- Csrf_time_limit:
The csrf time limit in seconds. Basically the amount of time a user has to submit a form, from the time it’s rendered.
Defaults to 1’200s (20 minutes).
- Mail:
A dictionary keyed by e-mail category (i.e. ‘marketing’, ‘transactional’) with the following subkeys:
host: The mail server to send e-mails from.
port: The port used for the mail server.
force_tls: True if TLS should be forced.
username: The mail username
password: The mail password
sender: The mail sender
use_directory: True if a mail directory should be used
directory: Path to the directory that should be used
- Mail_use_directory:
If true, mails are stored in the maildir defined through
mail_directory
. There, some other process is supposed to pick up the e-mails and send them.- Mail_directory:
The directory (maildir) where mails are stored if if
mail_use_directory
is set to True.- Sql_query_report:
Prints out a report sql queries for each request, unless False. Valid values are:
‘summary’ (only show the number of queries)
‘redundant’ (show summary and the actual redundant queries)
‘all’ (show summary and all executed queries)
Do not use in production!
- Profile:
If true, profiles the request and stores the result in the profiles folder with the following format:
YYYY-MM-DD hh:mm:ss.profile
Do not use in production!
- Print_exceptions:
If true, exceptions are printed to stderr. Note that you should usually configure logging through onegov.server. This is mainly used for certain unit tests where we use WSGI more directly.
- configure_organisation(*, enable_user_registration: bool = False, enable_yubikey: bool = False, disable_password_reset: bool = False, **cfg: Any) None [source]
- configure_mtan_hook(**cfg: Any) None [source]
This inserts an mtan hook by wrapping the callable we receive from the key lookup on get_view.
We only need to do this once per application instance and we don’t risk contaminating other applications, since each instance has its own dispatch callable.
This relies heavily on implementation details of reg.dispatch_method and is thus a little bit fragile, take care when upgrading to newer versions of reg!
- prepare_email(reply_to: email.headerregistry.Address | str | None = None, category: Literal['marketing', 'transactional'] = 'marketing', receivers: SequenceOrScalar[Address | str] = (), cc: SequenceOrScalar[Address | str] = (), bcc: SequenceOrScalar[Address | str] = (), subject: str | None = None, content: str | None = None, attachments: Iterable[Attachment | StrPath] = (), headers: dict[str, str] | None = None, plaintext: str | None = None) onegov.core.types.EmailJsonDict [source]
Wraps
onegov.core.framework.Framework.prepare_email()
, setting the reply_to address by using the reply address from the organisation settings.
- load_custom_texts() dict[str, str] | None [source]
Customer specific texts are specified in puppet repo, see loxo https://gitea.seantis.ch/operations/puppet/src/branch/master/nodes/loxo.seantis.ch.yaml#L183,193
Remember to create customtexts.yml in your local dev setup /usr/local/var/onegov/files/<org>/customtexts.yml
Example customtexts.yml: ```yaml custom texts:
(en) Custom admission course agreement: I agree to attend the .. (de) Custom admission course agreement: Ich erkläre mich bereit, ..
- property hashed_identity_key: bytes[source]
Take the sha-256 because we want a key that is 32 bytes long.
- checkout_button(button_label: str, title: str, price: Price | None, email: str, locale: str) str | None [source]
- redirect_after_login(identity: Identity | NoIdentity, request: onegov.org.request.OrgRequest, default: str) str | None [source]
Returns the path to redirect after login, given the request and the default login path, which is usually the current path.
Returns a path or None, if the default should be used.
- org.app.get_locale_negotiator() Callable[[Sequence[str], OrgRequest], str | None] [source]
- org.app.get_create_new_organisation_factory() Callable[[OrgApp, str], Organisation] [source]
- org.app.get_is_complete_userprofile_handler() Callable[[OrgRequest, str], bool] [source]
- org.app.get_public_ticket_messages() Collection[str] [source]
Returns a list of message types which are availble on the ticket status page, visible to anyone that knows the unguessable url.
- org.app.enable_iframes_tween_factory(app: OrgApp, handler: Callable[[OrgRequest], Response]) Callable[[OrgRequest], Response] [source]
- org.app.wrap_with_mtan_hook(func: Callable[[OrgApp, Any, OrgRequest], Any]) Callable[[OrgApp, Any, OrgRequest], Any] [source]