org.models.file
Contains the models describing files and images.
Classes
A general file (image, document, pdf, etc), referenced in the database. |
|
A general file (image, document, pdf, etc), referenced in the database. |
|
A set of files that belong together. Each file may be part of |
|
Manages filesets. |
|
Manages files. |
|
Manages files. |
|
Manages files. |
Module Contents
- class org.models.file.GroupFilesByDateMixin[FileT: onegov.file.File][source]
-
- get_date_intervals(today: datetime.datetime) collections.abc.Iterator[DateInterval][source]
- query_intervals[T, RowT](intervals: collections.abc.Iterable[DateInterval], before_filter: collections.abc.Callable[[sqlalchemy.orm.Query[FileT]], sqlalchemy.orm.Query[RowT]], process: collections.abc.Callable[[RowT], T]) collections.abc.Iterator[tuple[str, T]][source]
- query_intervals(intervals: collections.abc.Iterable[DateInterval], before_filter: None, process: collections.abc.Callable[[FileT], T]) collections.abc.Iterator[tuple[str, T]]
- query_intervals(intervals: collections.abc.Iterable[DateInterval], before_filter: None = None, *, process: collections.abc.Callable[[FileT], T]) collections.abc.Iterator[tuple[str, T]]
- query_intervals(intervals: collections.abc.Iterable[DateInterval], before_filter: collections.abc.Callable[[sqlalchemy.orm.Query[FileT]], sqlalchemy.orm.Query[Any]] | None = None, process: None = None) collections.abc.Iterator[tuple[str, Any]]
- grouped_by_date(today: datetime.datetime | None = None, id_only: Literal[True] = True) itertools.groupby[str, tuple[str, str]][source]
- grouped_by_date(today: datetime.datetime | None, id_only: Literal[False]) itertools.groupby[str, tuple[str, FileT]]
- grouped_by_date(today: datetime.datetime | None = None, *, id_only: Literal[False]) itertools.groupby[str, tuple[str, FileT]]
Returns all files grouped by natural language dates.
By default, only ids are returned, as this is enough to build the necessary links, which is what you usually want from a file.
The given date is expected to be in UTC.
- class org.models.file.GeneralFile[source]
Bases:
onegov.file.File,onegov.file.SearchableFileA general file (image, document, pdf, etc), referenced in the database.
Thanks to the use of Depot files can be seemingly stored in the database (with transaction guarantees), without actually storing it in the database.
- class org.models.file.ImageFile[source]
Bases:
onegov.file.FileA general file (image, document, pdf, etc), referenced in the database.
Thanks to the use of Depot files can be seemingly stored in the database (with transaction guarantees), without actually storing it in the database.
- class org.models.file.ImageSet[source]
Bases:
onegov.file.FileSet,onegov.org.models.extensions.AccessExtension,onegov.search.ORMSearchableA set of files that belong together. Each file may be part of none, one or many sets. Each set may containe none, one or many files.
The fileset uses uuids for public urls instead of a readable url-safe name, because files are meant to be always public with an unguessable url, and so the filesets containing files must also have the same property.
Otherwise we might not be able to guess the name the of the file, but we will be able to guess the name of a fileset containing files.
- fts_type_title[source]
Returns the display name for this type of document or a callable which accepts the current request as a single positional argument and returns the display name.
- fts_public = True[source]
Returns True if the model is available to be found by the public. If false, only editors/admins will see this object in the search results.
- class org.models.file.ImageSetCollection(session: sqlalchemy.orm.Session)[source]
Bases:
onegov.file.FileSetCollection[ImageSet]Manages filesets.
- class org.models.file.GeneralFileCollection(session: sqlalchemy.orm.Session, order_by: str = 'name')[source]
Bases:
onegov.file.FileCollection[GeneralFile],GroupFilesByDateMixin[GeneralFile]Manages files.
- Parameters:
session – The SQLAlchemy db session to use.
type – The polymorphic type to use and to filter for, or ‘*’ for all.
allow_duplicates –
Prevents duplicates if set to false. Duplicates are detected before pre-processing, so already stored files may be downloaded and added again, as they might have changed during the upload.
Note that this does not change existing files. It only prevents new duplicates from being added.
- _last_interval: DateInterval | None = None[source]
- property model_class: type[GeneralFile][source]
- property intervals: tuple[DateInterval, Ellipsis][source]
- class org.models.file.BaseImageFileCollection[FileT: onegov.file.File](session: sqlalchemy.orm.Session, type: Literal['*', 'generic'] = '*', allow_duplicates: bool = True)[source]
- class org.models.file.BaseImageFileCollection(session: sqlalchemy.orm.Session, type: str, allow_duplicates: bool = True)
Bases:
onegov.file.FileCollection[FileT],GroupFilesByDateMixin[FileT]Manages files.
- Parameters:
session – The SQLAlchemy db session to use.
type – The polymorphic type to use and to filter for, or ‘*’ for all.
allow_duplicates –
Prevents duplicates if set to false. Duplicates are detected before pre-processing, so already stored files may be downloaded and added again, as they might have changed during the upload.
Note that this does not change existing files. It only prevents new duplicates from being added.
- class org.models.file.ImageFileCollection(session: sqlalchemy.orm.Session)[source]
Bases:
BaseImageFileCollection[ImageFile]Manages files.
- Parameters:
session – The SQLAlchemy db session to use.
type – The polymorphic type to use and to filter for, or ‘*’ for all.
allow_duplicates –
Prevents duplicates if set to false. Duplicates are detected before pre-processing, so already stored files may be downloaded and added again, as they might have changed during the upload.
Note that this does not change existing files. It only prevents new duplicates from being added.