amsdal 0.5.23__cp311-cp311-macosx_10_9_universal2.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of amsdal might be problematic. Click here for more details.
- amsdal/Third-Party Materials - AMSDAL Dependencies - License Notices.md +1334 -0
- amsdal/__about__.py +4 -0
- amsdal/__about__.pyi +1 -0
- amsdal/__init__.py +23 -0
- amsdal/__init__.pyi +9 -0
- amsdal/__migrations__/0000_initial.py +36 -0
- amsdal/__migrations__/0001_create_class_file.py +61 -0
- amsdal/__migrations__/0002_create_class_file.py +109 -0
- amsdal/__migrations__/0003_update_class_file.py +91 -0
- amsdal/__migrations__/0004_update_class_file.py +45 -0
- amsdal/cloud/__init__.cpython-311-darwin.so +0 -0
- amsdal/cloud/__init__.pyi +0 -0
- amsdal/cloud/client.cpython-311-darwin.so +0 -0
- amsdal/cloud/client.pyi +57 -0
- amsdal/cloud/constants.cpython-311-darwin.so +0 -0
- amsdal/cloud/constants.pyi +13 -0
- amsdal/cloud/enums.cpython-311-darwin.so +0 -0
- amsdal/cloud/enums.pyi +68 -0
- amsdal/cloud/models/__init__.cpython-311-darwin.so +0 -0
- amsdal/cloud/models/__init__.pyi +0 -0
- amsdal/cloud/models/base.cpython-311-darwin.so +0 -0
- amsdal/cloud/models/base.pyi +247 -0
- amsdal/cloud/services/__init__.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/__init__.pyi +0 -0
- amsdal/cloud/services/actions/__init__.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/__init__.pyi +0 -0
- amsdal/cloud/services/actions/add_allowlist_ip.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/add_allowlist_ip.pyi +19 -0
- amsdal/cloud/services/actions/add_basic_auth.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/add_basic_auth.pyi +21 -0
- amsdal/cloud/services/actions/add_dependency.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/add_dependency.pyi +19 -0
- amsdal/cloud/services/actions/add_secret.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/add_secret.pyi +20 -0
- amsdal/cloud/services/actions/base.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/base.pyi +122 -0
- amsdal/cloud/services/actions/create_deploy.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/create_deploy.pyi +41 -0
- amsdal/cloud/services/actions/create_env.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/create_env.pyi +19 -0
- amsdal/cloud/services/actions/create_session.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/create_session.pyi +17 -0
- amsdal/cloud/services/actions/delete_allowlist_ip.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/delete_allowlist_ip.pyi +19 -0
- amsdal/cloud/services/actions/delete_basic_auth.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/delete_basic_auth.pyi +20 -0
- amsdal/cloud/services/actions/delete_dependency.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/delete_dependency.pyi +21 -0
- amsdal/cloud/services/actions/delete_env.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/delete_env.pyi +21 -0
- amsdal/cloud/services/actions/delete_secret.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/delete_secret.pyi +21 -0
- amsdal/cloud/services/actions/destroy_deploy.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/destroy_deploy.pyi +18 -0
- amsdal/cloud/services/actions/expose_db.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/expose_db.pyi +22 -0
- amsdal/cloud/services/actions/get_basic_auth_credentials.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/get_basic_auth_credentials.pyi +21 -0
- amsdal/cloud/services/actions/get_monitoring_info.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/get_monitoring_info.pyi +21 -0
- amsdal/cloud/services/actions/list_dependencies.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/list_dependencies.pyi +21 -0
- amsdal/cloud/services/actions/list_deploys.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/list_deploys.pyi +19 -0
- amsdal/cloud/services/actions/list_envs.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/list_envs.pyi +20 -0
- amsdal/cloud/services/actions/list_secrets.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/list_secrets.pyi +22 -0
- amsdal/cloud/services/actions/manager.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/manager.pyi +278 -0
- amsdal/cloud/services/actions/signup_action.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/signup_action.pyi +20 -0
- amsdal/cloud/services/actions/update_deploy.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/update_deploy.pyi +19 -0
- amsdal/cloud/services/auth/__init__.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/auth/__init__.pyi +0 -0
- amsdal/cloud/services/auth/base.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/auth/base.pyi +6 -0
- amsdal/cloud/services/auth/credentials.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/auth/credentials.pyi +30 -0
- amsdal/cloud/services/auth/manager.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/auth/manager.pyi +26 -0
- amsdal/cloud/services/auth/signup_service.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/auth/signup_service.pyi +32 -0
- amsdal/cloud/services/auth/token.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/auth/token.pyi +27 -0
- amsdal/configs/__init__.py +0 -0
- amsdal/configs/__init__.pyi +0 -0
- amsdal/configs/constants.py +33 -0
- amsdal/configs/constants.pyi +22 -0
- amsdal/configs/main.py +274 -0
- amsdal/configs/main.pyi +178 -0
- amsdal/context/__init__.py +0 -0
- amsdal/context/__init__.pyi +0 -0
- amsdal/context/manager.py +69 -0
- amsdal/context/manager.pyi +50 -0
- amsdal/contrib/__init__.cpython-311-darwin.so +0 -0
- amsdal/contrib/__init__.pyi +0 -0
- amsdal/contrib/app_config.py +7 -0
- amsdal/contrib/app_config.pyi +6 -0
- amsdal/contrib/auth/__init__.py +0 -0
- amsdal/contrib/auth/__init__.pyi +0 -0
- amsdal/contrib/auth/app.py +27 -0
- amsdal/contrib/auth/app.pyi +15 -0
- amsdal/contrib/auth/decorators/__init__.py +35 -0
- amsdal/contrib/auth/decorators/__init__.pyi +6 -0
- amsdal/contrib/auth/errors.py +7 -0
- amsdal/contrib/auth/errors.pyi +4 -0
- amsdal/contrib/auth/fixtures/basic_permissions.json +64 -0
- amsdal/contrib/auth/lifecycle/__init__.py +0 -0
- amsdal/contrib/auth/lifecycle/__init__.pyi +0 -0
- amsdal/contrib/auth/lifecycle/consumer.py +394 -0
- amsdal/contrib/auth/lifecycle/consumer.pyi +108 -0
- amsdal/contrib/auth/migrations/0000_initial.py +87 -0
- amsdal/contrib/auth/models/__init__.py +0 -0
- amsdal/contrib/auth/models/login_session.py +118 -0
- amsdal/contrib/auth/models/permission.py +23 -0
- amsdal/contrib/auth/models/user.py +106 -0
- amsdal/contrib/auth/settings.py +36 -0
- amsdal/contrib/auth/settings.pyi +26 -0
- amsdal/contrib/frontend_configs/__init__.py +0 -0
- amsdal/contrib/frontend_configs/__init__.pyi +0 -0
- amsdal/contrib/frontend_configs/app.py +24 -0
- amsdal/contrib/frontend_configs/app.pyi +19 -0
- amsdal/contrib/frontend_configs/constants.py +1 -0
- amsdal/contrib/frontend_configs/constants.pyi +1 -0
- amsdal/contrib/frontend_configs/conversion/__init__.py +5 -0
- amsdal/contrib/frontend_configs/conversion/__init__.pyi +3 -0
- amsdal/contrib/frontend_configs/conversion/convert.py +310 -0
- amsdal/contrib/frontend_configs/conversion/convert.pyi +22 -0
- amsdal/contrib/frontend_configs/lifecycle/__init__.py +0 -0
- amsdal/contrib/frontend_configs/lifecycle/__init__.pyi +0 -0
- amsdal/contrib/frontend_configs/lifecycle/consumer.py +306 -0
- amsdal/contrib/frontend_configs/lifecycle/consumer.pyi +98 -0
- amsdal/contrib/frontend_configs/migrations/0000_initial.py +227 -0
- amsdal/contrib/frontend_configs/migrations/0001_update_frontend_control_config.py +245 -0
- amsdal/contrib/frontend_configs/migrations/0002_add_button_and_invoke_actions.py +352 -0
- amsdal/contrib/frontend_configs/models/__init__.py +0 -0
- amsdal/contrib/frontend_configs/models/frontend_activator_config.py +22 -0
- amsdal/contrib/frontend_configs/models/frontend_config_async_validator.py +11 -0
- amsdal/contrib/frontend_configs/models/frontend_config_control_action.py +110 -0
- amsdal/contrib/frontend_configs/models/frontend_config_group_validator.py +21 -0
- amsdal/contrib/frontend_configs/models/frontend_config_option.py +12 -0
- amsdal/contrib/frontend_configs/models/frontend_config_skip_none_base.py +17 -0
- amsdal/contrib/frontend_configs/models/frontend_config_slider_option.py +13 -0
- amsdal/contrib/frontend_configs/models/frontend_config_text_mask.py +14 -0
- amsdal/contrib/frontend_configs/models/frontend_config_validator.py +28 -0
- amsdal/contrib/frontend_configs/models/frontend_control_config.py +108 -0
- amsdal/contrib/frontend_configs/models/frontend_model_config.py +14 -0
- amsdal/contrib/frontend_configs/utils.py +29 -0
- amsdal/contrib/frontend_configs/utils.pyi +17 -0
- amsdal/errors.py +31 -0
- amsdal/errors.pyi +12 -0
- amsdal/fixtures/__init__.cpython-311-darwin.so +0 -0
- amsdal/fixtures/__init__.pyi +0 -0
- amsdal/fixtures/manager.cpython-311-darwin.so +0 -0
- amsdal/fixtures/manager.pyi +170 -0
- amsdal/fixtures/utils.cpython-311-darwin.so +0 -0
- amsdal/fixtures/utils.pyi +9 -0
- amsdal/manager.cpython-311-darwin.so +0 -0
- amsdal/manager.pyi +265 -0
- amsdal/mixins/__init__.cpython-311-darwin.so +0 -0
- amsdal/mixins/__init__.pyi +0 -0
- amsdal/mixins/class_versions_mixin.cpython-311-darwin.so +0 -0
- amsdal/mixins/class_versions_mixin.pyi +12 -0
- amsdal/models/__init__.py +19 -0
- amsdal/models/core/__init__.py +0 -0
- amsdal/models/core/class_object.py +38 -0
- amsdal/models/core/class_property.py +26 -0
- amsdal/models/core/file.py +243 -0
- amsdal/models/core/fixture.py +25 -0
- amsdal/models/core/option.py +11 -0
- amsdal/models/core/storage_metadata.py +15 -0
- amsdal/models/core/validator.py +12 -0
- amsdal/models/mixins.py +31 -0
- amsdal/models/types/__init__.py +0 -0
- amsdal/models/types/object.py +26 -0
- amsdal/py.typed +0 -0
- amsdal/queryset/__init__.py +21 -0
- amsdal/queryset/__init__.pyi +6 -0
- amsdal/schemas/__init__.py +0 -0
- amsdal/schemas/__init__.pyi +0 -0
- amsdal/schemas/core/class_object/model.json +51 -0
- amsdal/schemas/core/class_object/properties/display_name.py +9 -0
- amsdal/schemas/core/class_property/model.json +41 -0
- amsdal/schemas/core/file/hooks/pre_create.py +24 -0
- amsdal/schemas/core/file/hooks/pre_update.py +24 -0
- amsdal/schemas/core/file/model.json +23 -0
- amsdal/schemas/core/file/properties/from_file.py +34 -0
- amsdal/schemas/core/file/properties/mimetype.py +13 -0
- amsdal/schemas/core/file/properties/str.py +6 -0
- amsdal/schemas/core/file/properties/to_file.py +24 -0
- amsdal/schemas/core/file/properties/validate_data.py +31 -0
- amsdal/schemas/core/fixture/model.json +35 -0
- amsdal/schemas/core/option/model.json +19 -0
- amsdal/schemas/core/storage_metadata/model.json +52 -0
- amsdal/schemas/core/validator/model.json +19 -0
- amsdal/schemas/interfaces.py +25 -0
- amsdal/schemas/interfaces.pyi +20 -0
- amsdal/schemas/manager.cpython-311-darwin.so +0 -0
- amsdal/schemas/manager.py +0 -0
- amsdal/schemas/manager.pyi +0 -0
- amsdal/schemas/mixins/__init__.py +0 -0
- amsdal/schemas/mixins/__init__.pyi +0 -0
- amsdal/schemas/mixins/check_dependencies_mixin.py +130 -0
- amsdal/schemas/mixins/check_dependencies_mixin.pyi +45 -0
- amsdal/schemas/mixins/verify_schemas_mixin.py +96 -0
- amsdal/schemas/mixins/verify_schemas_mixin.pyi +33 -0
- amsdal/schemas/repository.py +84 -0
- amsdal/schemas/repository.pyi +22 -0
- amsdal/schemas/types/anything/model.json +7 -0
- amsdal/schemas/types/array/model.json +7 -0
- amsdal/schemas/types/binary/model.json +7 -0
- amsdal/schemas/types/boolean/model.json +17 -0
- amsdal/schemas/types/date/model.json +7 -0
- amsdal/schemas/types/datetime/model.json +7 -0
- amsdal/schemas/types/dictionary/model.json +8 -0
- amsdal/schemas/types/number/model.json +8 -0
- amsdal/schemas/types/object/model.json +53 -0
- amsdal/schemas/types/string/model.json +8 -0
- amsdal/schemas/utils.py +16 -0
- amsdal/schemas/utils.pyi +10 -0
- amsdal/services/__init__.py +11 -0
- amsdal/services/__init__.pyi +4 -0
- amsdal/services/external_connections.py +262 -0
- amsdal/services/external_connections.pyi +190 -0
- amsdal/services/external_model_generator.py +350 -0
- amsdal/services/external_model_generator.pyi +134 -0
- amsdal/services/transaction_execution.cpython-311-darwin.so +0 -0
- amsdal/services/transaction_execution.pyi +93 -0
- amsdal/storages/__init__.py +20 -0
- amsdal/storages/__init__.pyi +8 -0
- amsdal/storages/file_system.py +214 -0
- amsdal/storages/file_system.pyi +36 -0
- amsdal/transactions/__init__.py +13 -0
- amsdal/transactions/__init__.pyi +4 -0
- amsdal/utils/__init__.py +0 -0
- amsdal/utils/__init__.pyi +0 -0
- amsdal/utils/contrib_paths.py +23 -0
- amsdal/utils/contrib_paths.pyi +14 -0
- amsdal/utils/rollback/__init__.py +440 -0
- amsdal/utils/rollback/__init__.pyi +38 -0
- amsdal/utils/tests/__init__.py +0 -0
- amsdal/utils/tests/enums.py +16 -0
- amsdal/utils/tests/factories.py +49 -0
- amsdal/utils/tests/helpers.py +331 -0
- amsdal/utils/tests/migrations.py +157 -0
- amsdal-0.5.23.dist-info/METADATA +373 -0
- amsdal-0.5.23.dist-info/RECORD +252 -0
- amsdal-0.5.23.dist-info/WHEEL +5 -0
- amsdal-0.5.23.dist-info/licenses/LICENSE.txt +107 -0
- amsdal-0.5.23.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from amsdal_data.connections.historical.schema_version_manager import AsyncHistoricalSchemaVersionManager, HistoricalSchemaVersionManager
|
|
2
|
+
|
|
3
|
+
class ClassVersionsMixin:
|
|
4
|
+
"""
|
|
5
|
+
Mixin class to manage class versions and related table schemas.
|
|
6
|
+
"""
|
|
7
|
+
@staticmethod
|
|
8
|
+
def _register_internal_classes(schema_version_manager: HistoricalSchemaVersionManager | AsyncHistoricalSchemaVersionManager) -> None: ...
|
|
9
|
+
@classmethod
|
|
10
|
+
def register_internal_classes(cls) -> None: ...
|
|
11
|
+
@classmethod
|
|
12
|
+
def aregister_internal_classes(cls) -> None: ...
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from amsdal_models.builder.validators.dict_validators import validate_non_empty_keys
|
|
2
|
+
from amsdal_models.builder.validators.options_validators import validate_options
|
|
3
|
+
from amsdal_models.classes.data_models.constraints import UniqueConstraint
|
|
4
|
+
from amsdal_models.classes.data_models.indexes import IndexInfo
|
|
5
|
+
from amsdal_models.classes.model import Model
|
|
6
|
+
from amsdal_models.classes.model import TypeModel
|
|
7
|
+
from amsdal_models.classes.relationships.many_reference_field import ManyReferenceField
|
|
8
|
+
from amsdal_models.classes.relationships.reference_field import ReferenceField
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
'IndexInfo',
|
|
12
|
+
'ManyReferenceField',
|
|
13
|
+
'Model',
|
|
14
|
+
'ReferenceField',
|
|
15
|
+
'TypeModel',
|
|
16
|
+
'UniqueConstraint',
|
|
17
|
+
'validate_non_empty_keys',
|
|
18
|
+
'validate_options',
|
|
19
|
+
]
|
|
File without changes
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
from typing import ClassVar
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
5
|
+
from amsdal_models.builder.validators.dict_validators import validate_non_empty_keys
|
|
6
|
+
from amsdal_models.classes.model import Model
|
|
7
|
+
from amsdal_utils.models.enums import ModuleType
|
|
8
|
+
from pydantic.fields import Field
|
|
9
|
+
from pydantic.functional_validators import field_validator
|
|
10
|
+
|
|
11
|
+
from amsdal.models.core.class_property import * # noqa: F403
|
|
12
|
+
from amsdal.models.core.storage_metadata import * # noqa: F403
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class ClassObject(Model):
|
|
16
|
+
__module_type__: ClassVar[ModuleType] = ModuleType.CORE
|
|
17
|
+
title: str = Field(title='Title')
|
|
18
|
+
type: str = Field(title='Type')
|
|
19
|
+
module_type: str = Field(title='Module Type')
|
|
20
|
+
properties: Optional[dict[str, Optional['ClassProperty']]] = Field(None, title='Properties') # noqa: F405, UP007
|
|
21
|
+
required: Optional[list[str]] = Field(None, title='Required') # noqa: UP007
|
|
22
|
+
custom_code: str | None = Field(None, title='Custom Code')
|
|
23
|
+
storage_metadata: Optional['StorageMetadata'] = Field(None, title='Storage metadata') # noqa: F405
|
|
24
|
+
|
|
25
|
+
@field_validator('properties')
|
|
26
|
+
@classmethod
|
|
27
|
+
def _non_empty_keys_properties(cls: type, value: Any) -> Any: # type: ignore # noqa: A003
|
|
28
|
+
return validate_non_empty_keys(value)
|
|
29
|
+
|
|
30
|
+
@property
|
|
31
|
+
def display_name(self) -> str:
|
|
32
|
+
"""
|
|
33
|
+
Returns the display name of the object.
|
|
34
|
+
|
|
35
|
+
Returns:
|
|
36
|
+
str: The display name, which is the title of the object.
|
|
37
|
+
"""
|
|
38
|
+
return self.title
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
from typing import ClassVar
|
|
3
|
+
|
|
4
|
+
from amsdal_models.builder.validators.dict_validators import validate_non_empty_keys
|
|
5
|
+
from amsdal_models.classes.model import TypeModel
|
|
6
|
+
from amsdal_utils.models.enums import ModuleType
|
|
7
|
+
from pydantic.fields import Field
|
|
8
|
+
from pydantic.functional_validators import field_validator
|
|
9
|
+
|
|
10
|
+
from amsdal.models.core.option import * # noqa: F403
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ClassProperty(TypeModel):
|
|
14
|
+
__module_type__: ClassVar[ModuleType] = ModuleType.CORE
|
|
15
|
+
title: str | None = Field(None, title='Title')
|
|
16
|
+
type: str = Field(title='Type')
|
|
17
|
+
default: Any | None = Field(None, title='Default')
|
|
18
|
+
options: list['Option'] | None = Field(None, title='Options') # noqa: F405
|
|
19
|
+
items: dict[str, Any | None] | None = Field(None, title='Items')
|
|
20
|
+
discriminator: str | None = Field(None, title='Discriminator')
|
|
21
|
+
extra: dict[str, Any | None] = Field(default_factory=dict, title='Extra')
|
|
22
|
+
|
|
23
|
+
@field_validator('items')
|
|
24
|
+
@classmethod
|
|
25
|
+
def _non_empty_keys_items(cls: type, value: Any) -> Any: # type: ignore # noqa: A003
|
|
26
|
+
return validate_non_empty_keys(value)
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import base64
|
|
2
|
+
import io
|
|
3
|
+
from contextlib import suppress
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import IO
|
|
6
|
+
from typing import Any
|
|
7
|
+
from typing import BinaryIO
|
|
8
|
+
from typing import ClassVar
|
|
9
|
+
|
|
10
|
+
from amsdal_models.classes.model import Model
|
|
11
|
+
from amsdal_models.storage.backends.db import AsyncFileWrapper
|
|
12
|
+
from amsdal_models.storage.backends.db import DBStorage
|
|
13
|
+
from amsdal_models.storage.base import Storage
|
|
14
|
+
from amsdal_utils.models.data_models.reference import Reference
|
|
15
|
+
from amsdal_utils.models.enums import ModuleType
|
|
16
|
+
from pydantic import PrivateAttr
|
|
17
|
+
from pydantic import model_validator
|
|
18
|
+
from pydantic.fields import Field
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class File(Model):
|
|
22
|
+
__module_type__: ClassVar[ModuleType] = ModuleType.CORE
|
|
23
|
+
filename: str = Field(title='Filename')
|
|
24
|
+
data: bytes | None = Field(default=None, title='Data')
|
|
25
|
+
size: float | None = Field(default=None, title='Size')
|
|
26
|
+
storage_address: Reference | None = Field(default=None, title='Storage Reference')
|
|
27
|
+
|
|
28
|
+
_source: BinaryIO | None = PrivateAttr(default=None)
|
|
29
|
+
_storage: Storage | None = PrivateAttr(default=None)
|
|
30
|
+
|
|
31
|
+
@property
|
|
32
|
+
def storage(self) -> Storage:
|
|
33
|
+
from amsdal.storages import default_storage
|
|
34
|
+
|
|
35
|
+
if self._storage:
|
|
36
|
+
return self._storage
|
|
37
|
+
|
|
38
|
+
if self.storage_address:
|
|
39
|
+
return Storage.from_storage_spec({'storage_class': self.storage_address.ref.resource})
|
|
40
|
+
|
|
41
|
+
return default_storage()
|
|
42
|
+
|
|
43
|
+
def __repr__(self) -> str:
|
|
44
|
+
return f'File<{self.filename}>({self.size or len(self.data or "") or 0} bytes)'
|
|
45
|
+
|
|
46
|
+
def __str__(self) -> str:
|
|
47
|
+
return repr(self)
|
|
48
|
+
|
|
49
|
+
def pre_create(self) -> None:
|
|
50
|
+
from amsdal_models.storage.persistence import persist_file
|
|
51
|
+
|
|
52
|
+
persist_file(self, storage=self.storage)
|
|
53
|
+
|
|
54
|
+
def pre_update(self) -> None:
|
|
55
|
+
from amsdal_models.storage.persistence import persist_file
|
|
56
|
+
|
|
57
|
+
persist_file(self, storage=self.storage)
|
|
58
|
+
|
|
59
|
+
async def apre_create(self) -> None:
|
|
60
|
+
from amsdal_models.storage.persistence import apersist_file
|
|
61
|
+
|
|
62
|
+
await apersist_file(self, storage=self.storage)
|
|
63
|
+
|
|
64
|
+
async def apre_update(self) -> None:
|
|
65
|
+
from amsdal_models.storage.persistence import apersist_file
|
|
66
|
+
|
|
67
|
+
await apersist_file(self, storage=self.storage)
|
|
68
|
+
|
|
69
|
+
@model_validator(mode='before')
|
|
70
|
+
@classmethod
|
|
71
|
+
def validate_model_data(cls, data: Any) -> Any:
|
|
72
|
+
if isinstance(data, dict):
|
|
73
|
+
if 'data' in data:
|
|
74
|
+
if data['data']:
|
|
75
|
+
data['data'] = cls.data_base64_decode(data['data'])
|
|
76
|
+
data['size'] = len(data['data'])
|
|
77
|
+
else:
|
|
78
|
+
data['size'] = 0
|
|
79
|
+
return data
|
|
80
|
+
|
|
81
|
+
@classmethod
|
|
82
|
+
def data_base64_decode(cls, data: Any) -> bytes:
|
|
83
|
+
if isinstance(data, str):
|
|
84
|
+
data = data.encode('utf-8')
|
|
85
|
+
|
|
86
|
+
is_base64: bool = False
|
|
87
|
+
|
|
88
|
+
with suppress(Exception):
|
|
89
|
+
is_base64 = base64.b64encode(base64.b64decode(data)) == data
|
|
90
|
+
|
|
91
|
+
if is_base64:
|
|
92
|
+
return base64.b64decode(data)
|
|
93
|
+
|
|
94
|
+
return data
|
|
95
|
+
|
|
96
|
+
@classmethod
|
|
97
|
+
def from_file(cls, file_or_path: Path | BinaryIO) -> 'File':
|
|
98
|
+
"""
|
|
99
|
+
Creates a `File` object from a file path or a binary file object.
|
|
100
|
+
|
|
101
|
+
Args:
|
|
102
|
+
file_or_path (Path | BinaryIO): The file path or binary file object.
|
|
103
|
+
|
|
104
|
+
Returns:
|
|
105
|
+
File: The created `File` object.
|
|
106
|
+
|
|
107
|
+
Raises:
|
|
108
|
+
ValueError: If the provided path is a directory.
|
|
109
|
+
"""
|
|
110
|
+
f: BinaryIO | io.BufferedReader
|
|
111
|
+
|
|
112
|
+
if isinstance(file_or_path, Path):
|
|
113
|
+
if file_or_path.is_dir():
|
|
114
|
+
msg = f'{file_or_path} is a directory'
|
|
115
|
+
raise ValueError(msg)
|
|
116
|
+
f = file_or_path.open('rb')
|
|
117
|
+
filename = file_or_path.name
|
|
118
|
+
size = file_or_path.stat().st_size
|
|
119
|
+
|
|
120
|
+
else:
|
|
121
|
+
f = file_or_path
|
|
122
|
+
filename = Path(getattr(f, 'name', 'unnamed')).name
|
|
123
|
+
|
|
124
|
+
try:
|
|
125
|
+
if f.seekable():
|
|
126
|
+
f.seek(0, io.SEEK_END)
|
|
127
|
+
size = f.tell()
|
|
128
|
+
f.seek(0)
|
|
129
|
+
else:
|
|
130
|
+
size = None
|
|
131
|
+
except (OSError, AttributeError):
|
|
132
|
+
size = None
|
|
133
|
+
|
|
134
|
+
obj = cls(filename=filename, size=size)
|
|
135
|
+
obj._source = f
|
|
136
|
+
return obj
|
|
137
|
+
|
|
138
|
+
@classmethod
|
|
139
|
+
def from_bytes(cls, filename: str, data: bytes) -> 'File':
|
|
140
|
+
"""
|
|
141
|
+
Creates a `File` object from a byte string.
|
|
142
|
+
|
|
143
|
+
Args:
|
|
144
|
+
filename (str): The filename of the file.
|
|
145
|
+
data (bytes): The byte string containing the file data.:
|
|
146
|
+
|
|
147
|
+
Returns:
|
|
148
|
+
File: The created `File` object.
|
|
149
|
+
"""
|
|
150
|
+
obj = cls(filename=filename, data=data, size=len(data))
|
|
151
|
+
return obj
|
|
152
|
+
|
|
153
|
+
def to_file(self, file_or_path: Path | BinaryIO) -> None:
|
|
154
|
+
"""
|
|
155
|
+
Writes the object's data to a file path or a binary file object.
|
|
156
|
+
|
|
157
|
+
Args:
|
|
158
|
+
file_or_path (Path | BinaryIO): The file path or binary file object where the data will be written.
|
|
159
|
+
|
|
160
|
+
Returns:
|
|
161
|
+
None
|
|
162
|
+
|
|
163
|
+
Raises:
|
|
164
|
+
ValueError: If the provided path is a directory.
|
|
165
|
+
"""
|
|
166
|
+
with self.open() as f:
|
|
167
|
+
if isinstance(file_or_path, Path):
|
|
168
|
+
if file_or_path.is_dir():
|
|
169
|
+
file_or_path = file_or_path / self.name
|
|
170
|
+
file_or_path.write_bytes(f.read()) # type: ignore[union-attr]
|
|
171
|
+
else:
|
|
172
|
+
file_or_path.write(f.read())
|
|
173
|
+
file_or_path.seek(0)
|
|
174
|
+
|
|
175
|
+
def url(self) -> str:
|
|
176
|
+
"""
|
|
177
|
+
Return a URL for this file using its storage_address.
|
|
178
|
+
|
|
179
|
+
Raises StateError if storage_address is missing.
|
|
180
|
+
"""
|
|
181
|
+
return self.storage.url(self)
|
|
182
|
+
|
|
183
|
+
def open(self, mode: str = 'rb') -> IO[Any]:
|
|
184
|
+
"""
|
|
185
|
+
Open a binary stream for reading (or other modes if supported) using storage_address.
|
|
186
|
+
|
|
187
|
+
Raises StateError if storage_address is missing.
|
|
188
|
+
"""
|
|
189
|
+
return self.storage.open(self, mode)
|
|
190
|
+
|
|
191
|
+
async def aurl(self) -> str:
|
|
192
|
+
"""
|
|
193
|
+
Async variant of url().
|
|
194
|
+
|
|
195
|
+
Uses the resolved storage to call aurl(); if the backend does not implement
|
|
196
|
+
async, falls back to the sync url().
|
|
197
|
+
"""
|
|
198
|
+
try:
|
|
199
|
+
return await self.storage.aurl(self) # type: ignore[attr-defined]
|
|
200
|
+
except NotImplementedError:
|
|
201
|
+
return self.storage.url(self)
|
|
202
|
+
|
|
203
|
+
async def aopen(self, mode: str = 'rb') -> Any:
|
|
204
|
+
"""
|
|
205
|
+
Async variant of open().
|
|
206
|
+
|
|
207
|
+
Uses the resolved storage to call aopen(); if the backend does not implement
|
|
208
|
+
async, falls back to the sync open().
|
|
209
|
+
"""
|
|
210
|
+
try:
|
|
211
|
+
return await self.storage.aopen(self, mode)
|
|
212
|
+
except NotImplementedError:
|
|
213
|
+
return AsyncFileWrapper(self.storage.open(self, mode))
|
|
214
|
+
|
|
215
|
+
@property
|
|
216
|
+
def mimetype(self) -> str | None:
|
|
217
|
+
"""
|
|
218
|
+
Returns the MIME type of the file based on its filename.
|
|
219
|
+
|
|
220
|
+
This method uses the `mimetypes` module to guess the MIME type of the file.
|
|
221
|
+
|
|
222
|
+
Returns:
|
|
223
|
+
str | None: The guessed MIME type of the file, or None if it cannot be determined.
|
|
224
|
+
"""
|
|
225
|
+
import mimetypes
|
|
226
|
+
|
|
227
|
+
return mimetypes.guess_type(self.filename)[0]
|
|
228
|
+
|
|
229
|
+
def read_bytes(self) -> bytes:
|
|
230
|
+
with self.open() as f:
|
|
231
|
+
return f.read()
|
|
232
|
+
|
|
233
|
+
async def aread_bytes(self) -> bytes:
|
|
234
|
+
async with await self.aopen() as f:
|
|
235
|
+
return await f.read()
|
|
236
|
+
|
|
237
|
+
def set_data(self, data: bytes | str) -> None:
|
|
238
|
+
if not isinstance(self.storage, DBStorage):
|
|
239
|
+
msg = 'Cannot set data on a file that is not stored in a database. Use `File.from_bytes` instead.'
|
|
240
|
+
raise ValueError(msg)
|
|
241
|
+
|
|
242
|
+
self.data = self.data_base64_decode(data)
|
|
243
|
+
self.size = len(self.data)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
from typing import ClassVar
|
|
3
|
+
|
|
4
|
+
from amsdal_models.builder.validators.dict_validators import validate_non_empty_keys
|
|
5
|
+
from amsdal_models.classes.data_models.constraints import UniqueConstraint
|
|
6
|
+
from amsdal_models.classes.model import Model
|
|
7
|
+
from amsdal_utils.models.enums import ModuleType
|
|
8
|
+
from pydantic.fields import Field
|
|
9
|
+
from pydantic.functional_validators import field_validator
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Fixture(Model):
|
|
13
|
+
__module_type__: ClassVar[ModuleType] = ModuleType.CORE
|
|
14
|
+
__constraints__: ClassVar[list[UniqueConstraint]] = [
|
|
15
|
+
UniqueConstraint(name='unq_fixture_external_id', fields=['external_id'])
|
|
16
|
+
]
|
|
17
|
+
class_name: str | None = Field(None, title='Class Name')
|
|
18
|
+
order: float | None = Field(None, title='Order')
|
|
19
|
+
external_id: str = Field(title='External ID')
|
|
20
|
+
data: dict[str, Any | None] = Field(title='Data')
|
|
21
|
+
|
|
22
|
+
@field_validator('data')
|
|
23
|
+
@classmethod
|
|
24
|
+
def _non_empty_keys_data(cls: type, value: Any) -> Any:
|
|
25
|
+
return validate_non_empty_keys(value)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from typing import ClassVar
|
|
2
|
+
|
|
3
|
+
from amsdal_models.classes.model import TypeModel
|
|
4
|
+
from amsdal_utils.models.enums import ModuleType
|
|
5
|
+
from pydantic.fields import Field
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Option(TypeModel):
|
|
9
|
+
__module_type__: ClassVar[ModuleType] = ModuleType.CORE
|
|
10
|
+
key: str = Field(title='Key')
|
|
11
|
+
value: str = Field(title='Value Type')
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from typing import ClassVar
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
from amsdal_models.classes.model import TypeModel
|
|
5
|
+
from amsdal_utils.models.enums import ModuleType
|
|
6
|
+
from pydantic.fields import Field
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class StorageMetadata(TypeModel):
|
|
10
|
+
__module_type__: ClassVar[ModuleType] = ModuleType.CORE
|
|
11
|
+
table_name: Optional[str] = Field(None, title='Table name') # noqa: UP007
|
|
12
|
+
db_fields: dict[str, list[str]] | None = Field(None, title='Database fields')
|
|
13
|
+
primary_key: Optional[list[str]] = Field(None, title='Primary key fields') # noqa: UP007
|
|
14
|
+
indexed: Optional[list[list[str]]] = Field(None, title='Indexed') # noqa: UP007
|
|
15
|
+
unique: Optional[list[list[str]]] = Field(None, title='Unique Fields') # noqa: UP007
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
from typing import ClassVar
|
|
3
|
+
|
|
4
|
+
from amsdal_models.classes.model import TypeModel
|
|
5
|
+
from amsdal_utils.models.enums import ModuleType
|
|
6
|
+
from pydantic.fields import Field
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Validator(TypeModel):
|
|
10
|
+
__module_type__: ClassVar[ModuleType] = ModuleType.CORE
|
|
11
|
+
name: str = Field(title='Validator Name')
|
|
12
|
+
data: Any = Field(title='Validator Data')
|
amsdal/models/mixins.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import datetime
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class TimestampMixin:
|
|
5
|
+
created_at: datetime.datetime | None = None
|
|
6
|
+
updated_at: datetime.datetime | None = None
|
|
7
|
+
|
|
8
|
+
def pre_create(self) -> None:
|
|
9
|
+
self.created_at = datetime.datetime.now(tz=datetime.UTC)
|
|
10
|
+
super().pre_create() # type: ignore[misc]
|
|
11
|
+
|
|
12
|
+
async def apre_create(self) -> None:
|
|
13
|
+
self.created_at = datetime.datetime.now(tz=datetime.UTC)
|
|
14
|
+
await super().apre_create() # type: ignore[misc]
|
|
15
|
+
|
|
16
|
+
def pre_update(self) -> None:
|
|
17
|
+
self.updated_at = datetime.datetime.now(tz=datetime.UTC)
|
|
18
|
+
|
|
19
|
+
if not self.created_at:
|
|
20
|
+
_metadata = self.get_metadata() # type: ignore[attr-defined]
|
|
21
|
+
self.created_at = datetime.datetime.fromtimestamp(_metadata.created_at / 1000, tz=datetime.UTC)
|
|
22
|
+
|
|
23
|
+
super().pre_update() # type: ignore[misc]
|
|
24
|
+
|
|
25
|
+
async def apre_update(self) -> None:
|
|
26
|
+
self.updated_at = datetime.datetime.now(tz=datetime.UTC)
|
|
27
|
+
if not self.created_at:
|
|
28
|
+
_metadata = await self.aget_metadata() # type: ignore[attr-defined]
|
|
29
|
+
self.created_at = datetime.datetime.fromtimestamp(_metadata.created_at / 1000, tz=datetime.UTC)
|
|
30
|
+
|
|
31
|
+
await super().apre_update() # type: ignore[misc]
|
|
File without changes
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
from typing import ClassVar
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
5
|
+
from amsdal_models.builder.validators.dict_validators import validate_non_empty_keys
|
|
6
|
+
from amsdal_models.classes.model import Model
|
|
7
|
+
from amsdal_utils.models.enums import ModuleType
|
|
8
|
+
from pydantic.fields import Field
|
|
9
|
+
from pydantic.functional_validators import field_validator
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Object(Model):
|
|
13
|
+
__module_type__: ClassVar[ModuleType] = ModuleType.TYPE
|
|
14
|
+
title: str = Field(title='Title', default='')
|
|
15
|
+
type: str = Field(title='Type', default='object')
|
|
16
|
+
module_type: str = Field(title='Module Type', default=ModuleType.CORE.value)
|
|
17
|
+
default: Optional[Any] = Field(None, title='Default') # noqa: UP007
|
|
18
|
+
properties: Optional[dict[str, Optional[Any]]] = Field(None, title='Properties') # noqa: UP007
|
|
19
|
+
required: Optional[list[str]] = Field(None, title='Required') # noqa: UP007
|
|
20
|
+
custom_code: Optional[str] = Field(None, title='Custom Code') # noqa: UP007
|
|
21
|
+
meta_class: Optional[str] = Field(None, title='Meta Class') # noqa: UP007
|
|
22
|
+
|
|
23
|
+
@field_validator('properties')
|
|
24
|
+
@classmethod
|
|
25
|
+
def _non_empty_keys_properties(cls: type, value: Any) -> Any: # type: ignore # noqa: A003
|
|
26
|
+
return validate_non_empty_keys(value)
|
amsdal/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from amsdal_models.querysets.base_queryset import QuerySet
|
|
2
|
+
from amsdal_models.querysets.base_queryset import QuerySetCount
|
|
3
|
+
from amsdal_models.querysets.base_queryset import QuerySetOne
|
|
4
|
+
from amsdal_models.querysets.base_queryset import QuerySetOneRequired
|
|
5
|
+
from amsdal_utils.query.data_models.filter import Filter
|
|
6
|
+
from amsdal_utils.query.enums import Lookup
|
|
7
|
+
from amsdal_utils.query.enums import OrderDirection
|
|
8
|
+
from amsdal_utils.query.utils import ConnectorEnum
|
|
9
|
+
from amsdal_utils.query.utils import Q
|
|
10
|
+
|
|
11
|
+
__all__ = [
|
|
12
|
+
'ConnectorEnum',
|
|
13
|
+
'Filter',
|
|
14
|
+
'Lookup',
|
|
15
|
+
'OrderDirection',
|
|
16
|
+
'Q',
|
|
17
|
+
'QuerySet',
|
|
18
|
+
'QuerySetCount',
|
|
19
|
+
'QuerySetOne',
|
|
20
|
+
'QuerySetOneRequired',
|
|
21
|
+
]
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
from amsdal_models.querysets.base_queryset import QuerySet as QuerySet, QuerySetCount as QuerySetCount, QuerySetOne as QuerySetOne, QuerySetOneRequired as QuerySetOneRequired
|
|
2
|
+
from amsdal_utils.query.data_models.filter import Filter as Filter
|
|
3
|
+
from amsdal_utils.query.enums import Lookup as Lookup, OrderDirection as OrderDirection
|
|
4
|
+
from amsdal_utils.query.utils import ConnectorEnum as ConnectorEnum, Q as Q
|
|
5
|
+
|
|
6
|
+
__all__ = ['ConnectorEnum', 'Filter', 'Lookup', 'OrderDirection', 'Q', 'QuerySet', 'QuerySetCount', 'QuerySetOne', 'QuerySetOneRequired']
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"title": "ClassObject",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"title": {
|
|
6
|
+
"title": "Title",
|
|
7
|
+
"type": "string"
|
|
8
|
+
},
|
|
9
|
+
"type": {
|
|
10
|
+
"title": "Type",
|
|
11
|
+
"type": "string"
|
|
12
|
+
},
|
|
13
|
+
"module_type": {
|
|
14
|
+
"title": "Module Type",
|
|
15
|
+
"type": "string"
|
|
16
|
+
},
|
|
17
|
+
"properties": {
|
|
18
|
+
"title": "Properties",
|
|
19
|
+
"type": "dictionary",
|
|
20
|
+
"items": {
|
|
21
|
+
"key": {
|
|
22
|
+
"type": "string"
|
|
23
|
+
},
|
|
24
|
+
"value": {
|
|
25
|
+
"type": "ClassProperty"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"required": {
|
|
30
|
+
"title": "Required",
|
|
31
|
+
"type": "array",
|
|
32
|
+
"items": {
|
|
33
|
+
"type": "string"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"custom_code": {
|
|
37
|
+
"title": "Custom Code",
|
|
38
|
+
"type": "string"
|
|
39
|
+
},
|
|
40
|
+
"storage_metadata": {
|
|
41
|
+
"title": "Storage metadata",
|
|
42
|
+
"type": "StorageMetadata"
|
|
43
|
+
},
|
|
44
|
+
"meta_class": {
|
|
45
|
+
"title": "Meta Class",
|
|
46
|
+
"type": "string",
|
|
47
|
+
"default": "ClassObject"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"required": []
|
|
51
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"title": "ClassProperty",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"title": {
|
|
6
|
+
"title": "Title",
|
|
7
|
+
"type": "string"
|
|
8
|
+
},
|
|
9
|
+
"type": {
|
|
10
|
+
"title": "Type",
|
|
11
|
+
"type": "string"
|
|
12
|
+
},
|
|
13
|
+
"default": {
|
|
14
|
+
"title": "Default",
|
|
15
|
+
"type": "anything"
|
|
16
|
+
},
|
|
17
|
+
"options": {
|
|
18
|
+
"title": "Options",
|
|
19
|
+
"type": "array",
|
|
20
|
+
"items": {
|
|
21
|
+
"type": "Option"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"items": {
|
|
25
|
+
"title": "Items",
|
|
26
|
+
"type": "dictionary",
|
|
27
|
+
"items": {
|
|
28
|
+
"key": {"type": "string"},
|
|
29
|
+
"value": {"type": "anything"}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"discriminator": {
|
|
33
|
+
"title": "Discriminator",
|
|
34
|
+
"type": "string"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"required": [
|
|
38
|
+
"type"
|
|
39
|
+
],
|
|
40
|
+
"meta_class": "TypeMeta"
|
|
41
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
def pre_create(self) -> None: # type: ignore[no-untyped-def]
|
|
2
|
+
"""
|
|
3
|
+
Prepares the object for creation by setting its size attribute.
|
|
4
|
+
|
|
5
|
+
This method calculates the size of the object's data and assigns it to the size attribute.
|
|
6
|
+
If the data is None, it defaults to an empty byte string.
|
|
7
|
+
|
|
8
|
+
Args:
|
|
9
|
+
None
|
|
10
|
+
"""
|
|
11
|
+
self.size = len(self.data or b'')
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
async def apre_create(self) -> None: # type: ignore[no-untyped-def]
|
|
15
|
+
"""
|
|
16
|
+
Prepares the object for creation by setting its size attribute.
|
|
17
|
+
|
|
18
|
+
This method calculates the size of the object's data and assigns it to the size attribute.
|
|
19
|
+
If the data is None, it defaults to an empty byte string.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
None
|
|
23
|
+
"""
|
|
24
|
+
self.size = len(self.data or b'')
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
def pre_update(self): # type: ignore[no-untyped-def]
|
|
2
|
+
"""
|
|
3
|
+
Prepares the object for update by setting its size attribute.
|
|
4
|
+
|
|
5
|
+
This method calculates the size of the object's data and assigns it to the size attribute.
|
|
6
|
+
If the data is None, it defaults to an empty byte string.
|
|
7
|
+
|
|
8
|
+
Args:
|
|
9
|
+
None
|
|
10
|
+
"""
|
|
11
|
+
self.size = len(self.data or b'')
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
async def apre_update(self): # type: ignore[no-untyped-def]
|
|
15
|
+
"""
|
|
16
|
+
Prepares the object for update by setting its size attribute.
|
|
17
|
+
|
|
18
|
+
This method calculates the size of the object's data and assigns it to the size attribute.
|
|
19
|
+
If the data is None, it defaults to an empty byte string.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
None
|
|
23
|
+
"""
|
|
24
|
+
self.size = len(self.data or b'')
|