agency.app
Classes
Baseclass for Morepath OneGov applications. |
Functions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Module Contents
- class agency.app.AgencyApp[source]
Bases:
onegov.org.OrgApp
,onegov.api.ApiApp
Baseclass for Morepath OneGov applications.
- 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
- property filestorage: fs.base.SubFS[fs.base.FS][source]
Returns a filestorage object bound to the current application. Based on this nifty module:
https://docs.pyfilesystem.org/en/latest/
The file storage returned is guaranteed to be independent of other applications (the scope is the application_id, not just the class).
There is no guarantee as to what file storage backend is actually used. It’s quite possible that the file storage will be somewhere online in the future (e.g. S3).
Therefore, the urls for the file storage should always be acquired through
onegov.core.request.CoreRequest.filestorage_link()
.The backend is configured through
configure_application()
.For a list of methods available on the resulting object, consult this list: https://docs.pyfilesystem.org/en/latest/interface.html.
If no filestorage is available, this returns None. See
self.has_filestorage
.WARNING: Files stored in the filestorage are available publicly! All someone has to do is to guess the filename. To get an unguessable filename use
onegov.core.filestorage.random_filename()
.The reason for this is the fact that filestorage may be something external in the future.
This should not deter you from using this for user uploads, though you should be careful. If you want to be sure that your application stores files locally, use some other ways of storing those files.
Example:
from onegov.core import filestorage filename = filestorage.random_filename() app.filestorage.writetext(filename, 'Lorem Ipsum') # returns either an url like '/files/4ec56cc005c594880a...' # or maybe 'https://amazonaws.com/onegov-cloud/32746/220592/q...' request.filestorage_link(filename)
- agency.app.get_create_new_organisation_factory() Callable[[AgencyApp, str], Organisation] [source]
- agency.app.get_template_variables(request: onegov.agency.request.AgencyRequest) onegov.core.types.RenderData [source]
- agency.app.get_api_endpoints() list[type[ApiEndpoint[Any]]] [source]