org.app

Contains the base application used by other applications.

Module Contents

Classes

OrgApp

Baseclass for Morepath OneGov applications.

KeyLookupWithMTANHook

Functions

get_shared_assets_path(→ str)

get_i18n_used_locales(→ set[str])

get_i18n_localedirs(→ list[str])

get_i18n_default_locale(→ str)

get_locale_negotiator(→ Callable[[Sequence[str], ...)

get_static_directory(→ str)

get_template_directory(→ str)

get_theme(→ onegov.org.theme.OrgTheme)

org_content_security_policy(...)

get_create_new_organisation_factory(...)

get_status_mail_roles(→ Collection[str])

get_ticket_manager_roles(→ Collection[str])

get_require_complete_userprofile(→ bool)

get_is_complete_userprofile_handler(...)

get_default_directory_search_widget(→ None)

get_default_event_search_widget(→ None)

get_public_ticket_messages(→ Collection[str])

Returns a list of message types which are availble on the ticket

get_disabled_extensions(→ Collection[str])

enable_iframes_tween_factory(→ Callable[[OrgRequest], ...)

get_js_path(→ str)

get_css_path(→ str)

get_webasset_output(→ str)

get_sortable_asset(→ Iterator[str])

get_fullcalendar_asset(→ Iterator[str])

get_reservation_list_asset(→ Iterator[str])

get_code_editor_asset(→ Iterator[str])

get_editor_asset(→ Iterator[str])

get_timeline_asset(→ Iterator[str])

get_redactor_asset(→ Iterator[str])

get_upload_asset(→ Iterator[str])

get_editalttext_asset(→ Iterator[str])

get_prompt(→ Iterator[str])

get_photoswipe_asset(→ Iterator[str])

get_tags_input(→ Iterator[str])

get_filehash(→ Iterator[str])

get_monthly_view(→ Iterator[str])

get_common_asset(→ Iterator[str])

get_fontpreview_asset(→ Iterator[str])

get_scroll_to_username_asset(→ Iterator[str])

get_all_blank_asset(→ Iterator[str])

wrap_with_mtan_hook(→ Callable[[OrgApp, Any, ...)

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.

property theme_options: dict[str, Any][source]

Returns the application-bound theme options.

property font_family: str | None[source]
property custom_event_tags: list[str] | None[source]
property allowed_iframe_domains: list[str][source]
property hashed_identity_key: bytes[source]

Take the sha-256 because we want a key that is 32 bytes long.

property custom_event_form_lead: str | None[source]
serve_static_files = True[source]
request_class[source]
homepage_widget[source]
export[source]
directory_search_widget[source]
event_search_widget[source]
settings_view[source]
boardlet[source]
send_ticket_statistics = True[source]
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!

org() onegov.org.models.Organisation[source]
root_pages() tuple[onegov.page.Page, Ellipsis][source]
pages_tree() tuple[onegov.page.Page, Ellipsis][source]

This is the entire pages tree preloaded into the individual parent/children attributes. We optimize this as much as possible by performing the recursive join in Python, rather than SQL.

homepage_template() onegov.core.templates.PageTemplate[source]
ticket_count() onegov.ticket.collection.TicketCount[source]
ticket_permissions() dict[str, dict[str | None, list[str]]][source]
homepage_pages() dict[int, list[onegov.org.models.Topic]][source]
publications_count() int[source]
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_event_tags() list[str] | None[source]
load_allowed_iframe_domains() list[str] | None[source]
load_custom_event_form_lead() str | None[source]
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_shared_assets_path() str[source]
org.app.get_i18n_used_locales() set[str][source]
org.app.get_i18n_localedirs() list[str][source]
org.app.get_i18n_default_locale() str[source]
org.app.get_locale_negotiator() Callable[[Sequence[str], OrgRequest], str | None][source]
org.app.get_static_directory() str[source]
org.app.get_template_directory() str[source]
org.app.get_theme() onegov.org.theme.OrgTheme[source]
org.app.org_content_security_policy() more.content_security.ContentSecurityPolicy[source]
org.app.get_create_new_organisation_factory() Callable[[OrgApp, str], Organisation][source]
org.app.get_status_mail_roles() Collection[str][source]
org.app.get_ticket_manager_roles() Collection[str][source]
org.app.get_require_complete_userprofile() bool[source]
org.app.get_is_complete_userprofile_handler() Callable[[OrgRequest, str], bool][source]
org.app.get_default_directory_search_widget() None[source]
org.app.get_default_event_search_widget() None[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.get_disabled_extensions() Collection[str][source]
org.app.enable_iframes_tween_factory(app: OrgApp, handler: Callable[[OrgRequest], Response]) Callable[[OrgRequest], Response][source]
org.app.get_js_path() str[source]
org.app.get_css_path() str[source]
org.app.get_webasset_output() str[source]
org.app.get_sortable_asset() Iterator[str][source]
org.app.get_fullcalendar_asset() Iterator[str][source]
org.app.get_reservation_list_asset() Iterator[str][source]
org.app.get_code_editor_asset() Iterator[str][source]
org.app.get_editor_asset() Iterator[str][source]
org.app.get_timeline_asset() Iterator[str][source]
org.app.get_redactor_asset() Iterator[str][source]
org.app.get_upload_asset() Iterator[str][source]
org.app.get_editalttext_asset() Iterator[str][source]
org.app.get_prompt() Iterator[str][source]
org.app.get_photoswipe_asset() Iterator[str][source]
org.app.get_tags_input() Iterator[str][source]
org.app.get_filehash() Iterator[str][source]
org.app.get_monthly_view() Iterator[str][source]
org.app.get_common_asset() Iterator[str][source]
org.app.get_fontpreview_asset() Iterator[str][source]
org.app.get_scroll_to_username_asset() Iterator[str][source]
org.app.get_all_blank_asset() Iterator[str][source]
org.app.wrap_with_mtan_hook(func: Callable[[OrgApp, Any, OrgRequest], Any]) Callable[[OrgApp, Any, OrgRequest], Any][source]
class org.app.KeyLookupWithMTANHook(key_lookup: reg.dispatch._KeyLookup)[source]
component(key: Sequence[Any]) Callable[..., Any] | None[source]
fallback(key: Sequence[Any]) Callable[..., Any] | None[source]
all(key: Sequence[Any]) Iterator[Callable[..., Any]][source]