org.models.file
¶
Contains the models describing files and images.
Module Contents¶
Classes¶
Abstract base class for generic types. |
|
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. |
Attributes¶
- class org.models.file.GroupFilesByDateMixin[source]¶
Bases:
Generic
[FileT
]Abstract base class for generic types.
A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:
class Mapping(Generic[KT, VT]): def __getitem__(self, key: KT) -> VT: ... # Etc.
This class can then be used as follows:
def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: try: return mapping[key] except KeyError: return default
- get_date_intervals(today: datetime.datetime) Iterator[DateInterval] [source]¶
- query_intervals(intervals: Iterable[DateInterval], before_filter: Callable[[Query[FileT]], Query[_RowT]], process: Callable[[_RowT], _T]) Iterator[tuple[str, _T]] [source]¶
- query_intervals(intervals: Iterable[DateInterval], before_filter: None, process: Callable[[FileT], _T]) Iterator[tuple[str, _T]]
- query_intervals(intervals: Iterable[DateInterval], before_filter: None = None, *, process: Callable[[FileT], _T]) Iterator[tuple[str, _T]]
- query_intervals(intervals: Iterable[DateInterval], before_filter: Callable[[Query[FileT]], Query[Any]] | None = None, process: None = None) Iterator[tuple[str, Any]]
- grouped_by_date(today: datetime.datetime | None = None, id_only: Literal[True] = True) groupby[str, tuple[str, str]] [source]¶
- grouped_by_date(today: datetime.datetime | None, id_only: Literal[False]) groupby[str, tuple[str, FileT]]
- grouped_by_date(today: datetime.datetime | None = None, *, id_only: Literal[False]) 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.SearchableFile
A 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.File
A 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.ORMSearchable
A 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.
- 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.
- intervals() tuple[DateInterval, Ellipsis] [source]¶
- class org.models.file.BaseImageFileCollection(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.