architectonics 0.0.34__py3-none-any.whl → 0.0.35__py3-none-any.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.
@@ -1,7 +1,6 @@
1
- from dataclasses import dataclass, field
1
+ from dataclasses import asdict, dataclass, field
2
2
  from datetime import datetime
3
3
  import uuid
4
- from dataclasses import asdict
5
4
 
6
5
 
7
6
  @dataclass(
@@ -0,0 +1,8 @@
1
+ from dataclasses import dataclass
2
+
3
+ from architectonics.core.models.base_model import BaseModel
4
+
5
+
6
+ @dataclass
7
+ class DeletedModel(BaseModel):
8
+ id: str
@@ -6,6 +6,7 @@ from starlette.status import (
6
6
  )
7
7
 
8
8
  from architectonics.core.models.base_model import BaseModel
9
+ from architectonics.core.models.deleted_models import DeletedModel
9
10
  from architectonics.core.result.service_result import ServiceResult
10
11
  from architectonics.core.services.base_schemas import (
11
12
  BaseModelCreateSchema,
@@ -97,39 +98,30 @@ class BaseService:
97
98
  model=model,
98
99
  )
99
100
  except IntegrityErrorException as error:
100
- return ServiceResult[BaseModel, BaseModelValidationErrors].failure(
101
- error_message=error
102
- )
101
+ return ServiceResult[BaseModel, BaseModelValidationErrors].failure(error_message=error)
103
102
  except ObjectNotFoundException:
104
103
  return ServiceResult[BaseModel, BaseModelValidationErrors].failure(
105
104
  error_message="object_not_found",
106
105
  )
107
106
 
108
- return ServiceResult[BaseModel, BaseModelValidationErrors].success(
109
- value=model
110
- )
111
-
112
- """
113
-
114
-
115
-
116
-
117
-
107
+ return ServiceResult[BaseModel, BaseModelValidationErrors].success(value=model)
118
108
 
119
109
  async def delete_model(
120
110
  self,
121
111
  model_id: str,
122
- ) -> tuple[None | str, str | dict[str, list[str]] | None, int]:
123
-
124
- _, errors, status_code = await self.get_model(
125
- model_id=model_id,
126
- )
112
+ ) -> ServiceResult[DeletedModel, BaseModelValidationErrors]:
127
113
 
128
- if errors:
129
- return None, errors, status_code
114
+ try:
115
+ await self._repository.delete_model(
116
+ model_id=model_id,
117
+ )
118
+ except ObjectNotFoundException:
119
+ return ServiceResult[BaseModel, BaseModelValidationErrors].failure(
120
+ error_message="object_not_found",
121
+ )
130
122
 
131
- await self._repository.delete_model(
132
- model_id=model_id,
123
+ return ServiceResult[DeletedModel, BaseModelValidationErrors].success(
124
+ value=DeletedModel(
125
+ id=model_id,
126
+ ),
133
127
  )
134
-
135
- return "object_deleted", None, HTTP_200_OK"""
@@ -2,17 +2,17 @@ from abc import ABC
2
2
  from typing import Callable
3
3
 
4
4
  from asyncpg.exceptions import ForeignKeyViolationError
5
+ from sqlalchemy import delete, select, update
6
+ from sqlalchemy.exc import IntegrityError
7
+ from sqlalchemy.ext.asyncio import AsyncSession
8
+
9
+ from architectonics.core.models.base_model import BaseModel
5
10
  from architectonics.infrastructure.entities.base_entity import BaseEntity
6
11
  from architectonics.infrastructure.repositories.base_exceptions import (
7
12
  IntegrityErrorException,
8
13
  ObjectAlreadyExistsException,
9
14
  ObjectNotFoundException,
10
15
  )
11
- from sqlalchemy import delete, select, update
12
- from sqlalchemy.exc import IntegrityError
13
- from sqlalchemy.ext.asyncio import AsyncSession
14
-
15
- from architectonics.core.models.base_model import BaseModel
16
16
 
17
17
 
18
18
  class BaseRepository(ABC):
@@ -116,7 +116,13 @@ class BaseRepository(ABC):
116
116
  )
117
117
 
118
118
  async with self.get_session() as session:
119
- await session.execute(statement)
119
+ result = await session.execute(
120
+ statement=statement,
121
+ )
122
+
123
+ if result.rowcount == 0:
124
+ raise ObjectNotFoundException()
125
+
120
126
  await session.commit()
121
127
 
122
128
  async def get_models_list(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: architectonics
3
- Version: 0.0.34
3
+ Version: 0.0.35
4
4
  Summary:
5
5
  Author: Your Name
6
6
  Author-email: you@example.com
@@ -7,12 +7,13 @@ architectonics/core/config/application_settings.py,sha256=DmCjQCbm4BsxMoZuQ212Pj
7
7
  architectonics/core/factory/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  architectonics/core/factory/factory.py,sha256=C9TDhkhq5lcdcBnICy4DgJj0yjeCIhq-UVSwaf-aTmM,748
9
9
  architectonics/core/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
- architectonics/core/models/base_model.py,sha256=kuYPZ-Z7lR7Sbj3yOVVN7HeCgs6_Dg0dtmF-kjIqkFo,686
10
+ architectonics/core/models/base_model.py,sha256=-dT4UqQCSW41Ip6Cb41Bkudh45Co71EsReYOdwF4BMs,663
11
+ architectonics/core/models/deleted_models.py,sha256=9hqdZgCC2JhAriA_GA7P2uA32rk5UAEXvGA3u8HVIME,151
11
12
  architectonics/core/result/error_message.py,sha256=sMIMVt58wGo33E9lD4r6k9tRkgL2TpO7yjX-BZc6PHI,97
12
13
  architectonics/core/result/service_result.py,sha256=VwjegZKR38ocAEriY_0rnnPn69u09HDja4y3iKq0z9w,1879
13
14
  architectonics/core/schemas/base_schemas.py,sha256=4ghwg7h06uIoBRkXGtWDFQA7Yb6Hvo4AsIA80xmSlFk,415
14
15
  architectonics/core/services/base_schemas.py,sha256=9PpCcf5GaE68s2VDKiAWRNufhFL2iN5djOcMsir8HMk,295
15
- architectonics/core/services/base_service.py,sha256=fTd0oxeHhIlfMijtsJZRz-mLm8ZY9lkZu4WMvZjBZ7E,4001
16
+ architectonics/core/services/base_service.py,sha256=hYYQ73icgMnwnDRjGd1rqYlE5qvsVvneKHosjEEHysU,4149
16
17
  architectonics/core/validation/base_model_validation_errors.py,sha256=Z3nGM3XaHbkW0z2qhVjwd8t0EbYULArIHARa0IYCNVg,306
17
18
  architectonics/infrastructure/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
19
  architectonics/infrastructure/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -21,7 +22,7 @@ architectonics/infrastructure/config/database_settings.py,sha256=d1HA8rQj3LMACEv
21
22
  architectonics/infrastructure/entities/base_entity.py,sha256=EqmmY2aVzqIdgJPsKBUBtesOfsmSSNrRuBGGQQ6bpJA,818
22
23
  architectonics/infrastructure/repositories/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
24
  architectonics/infrastructure/repositories/base_exceptions.py,sha256=kOeu3p90LHMxCcp2cCL_Anrsz4CTLtELWqma_RCQSqM,303
24
- architectonics/infrastructure/repositories/base_repository.py,sha256=fT4X-b89H8vnrAMJ9oEXxxlv6JI87IH0iwruvzlmUs4,3448
25
- architectonics-0.0.34.dist-info/WHEEL,sha256=y3eDiaFVSNTPbgzfNn0nYn5tEn1cX6WrdetDlQM4xWw,83
26
- architectonics-0.0.34.dist-info/METADATA,sha256=vEwyBxaatz4FINRpwP_Fg6LxYQhJRC8M82zpjMU715g,469
27
- architectonics-0.0.34.dist-info/RECORD,,
25
+ architectonics/infrastructure/repositories/base_repository.py,sha256=y9Q2SPj1t55gRrUaNrSZ7SnuEGVYRAlwuU3fhNwtzt8,3585
26
+ architectonics-0.0.35.dist-info/WHEEL,sha256=y3eDiaFVSNTPbgzfNn0nYn5tEn1cX6WrdetDlQM4xWw,83
27
+ architectonics-0.0.35.dist-info/METADATA,sha256=xAEwbOoRpQui4bDEHoq492lae0wJ4ZrVXjEFseJtgpQ,469
28
+ architectonics-0.0.35.dist-info/RECORD,,