Skip to content

Commit 4cbef48

Browse files
authored
Merge pull request #89 from eadwinCode/package_dependency_fix
ellar package dependency refactor
2 parents f187293 + 0e701f6 commit 4cbef48

File tree

330 files changed

+2473
-1633
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

330 files changed

+2473
-1633
lines changed

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ ellar create-module car
8585
## **Add Schema**
8686
In `car/schema.py`, lets add some serializer for car input and output data
8787
```python
88-
from ellar.core.serializer import Serializer
88+
from ellar.common import Serializer
8989

9090
class CarSerializer(Serializer):
9191
name: str
@@ -155,9 +155,8 @@ In `car/controllers.py`, lets create `CarController`
155155

156156
```python
157157
import typing as t
158-
from ellar.common import Controller, delete, get, put, post
159-
from ellar.core import ControllerBase
160-
from ellar.core.exceptions import NotFound
158+
from ellar.common import Controller, delete, get, put, post, ControllerBase
159+
from ellar.common.exceptions import NotFound
161160
from .schemas import CarSerializer, RetrieveCarSerializer
162161
from .services import CarDummyDB
163162

@@ -225,8 +224,8 @@ class CarModule(ModuleBase):
225224
## **Registering Module**
226225
Ellar is not aware of `CarModule` yet, so we need to add it to the `modules` list of `ApplicationModule` at the `carsite/root_module.py`.
227226
```python
228-
from ellar.common import Module, exception_handler
229-
from ellar.core import IHostContext, ModuleBase, JSONResponse, Response
227+
from ellar.common import Module, exception_handler, JSONResponse, Response, IHostContext
228+
from ellar.core import ModuleBase
230229

231230
from ellar.samples.modules import HomeModule
232231
from .apps.car.module import CarModule

docs/basics/execution-context.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ For example, the `catch()` method of an **exception handlers** is called with an
1515
```python
1616
# project_name/apps/custom_exceptions.py
1717
import typing as t
18-
from ellar.core.exceptions import IExceptionHandler
19-
from ellar.core.context import IHostContext
20-
from starlette.responses import Response
18+
from ellar.common import IExceptionHandler, IHostContext, Response
2119

2220
class MyCustomException(Exception):
2321
pass
@@ -147,7 +145,8 @@ that will handler the current request.
147145

148146
```python
149147
import typing
150-
from ellar.core import HostContext, ControllerBase
148+
from ellar.common import ControllerBase
149+
from ellar.core import HostContext
151150

152151

153152
class ExecutionContext(HostContext):
@@ -196,8 +195,7 @@ We can then access this metadata from within our class to make certain decisions
196195
```python
197196
# project_name/apps/cars/controllers.py
198197

199-
from ellar.common import Body, Controller, post, set_metadata
200-
from ellar.core import ControllerBase
198+
from ellar.common import Body, Controller, post, set_metadata, ControllerBase
201199
from .schemas import CreateCarSerializer
202200

203201

@@ -218,8 +216,7 @@ Instead, create your own decorators, as shown below:
218216
```python
219217
# project_name/apps/cars/controllers.py
220218
import typing
221-
from ellar.common import Body, Controller, post, set_metadata
222-
from ellar.core import ControllerBase
219+
from ellar.common import Body, Controller, post, set_metadata, ControllerBase
223220
from .schemas import CreateCarSerializer
224221

225222

@@ -246,8 +243,8 @@ To access the route's role(s) (custom metadata), we'll use the `Reflector` helpe
246243
```python
247244
# project_name/apps/cars/guards.py
248245
from ellar.di import injectable
249-
from ellar.core import GuardCanActivate, IExecutionContext
250-
from ellar.services import Reflector
246+
from ellar.common import GuardCanActivate, IExecutionContext
247+
from ellar.core.services import Reflector
251248

252249

253250
@injectable()
@@ -269,8 +266,7 @@ Next, we apply the `RoleGuard` to `CarController`
269266
```python
270267
# project_name/apps/cars/controllers.py
271268
import typing
272-
from ellar.common import Body, Controller, post, set_metadata, Guards
273-
from ellar.core import ControllerBase
269+
from ellar.common import Body, Controller, post, set_metadata, Guards, ControllerBase
274270
from .schemas import CreateCarSerializer
275271
from .guards import RoleGuard
276272

docs/basics/testing.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,8 @@ In same way, we can override `Guards` used in controllers during testing. For ex
155155

156156
```python
157157
import typing
158-
from ellar.compatible.dict import AttributeDict
159-
from ellar.common import Guards, Controller
160-
from ellar.core import ControllerBase
158+
from ellar.common.compatible import AttributeDict
159+
from ellar.common import Guards, Controller, ControllerBase
161160
from ellar.core.guard import HttpBearerAuth
162161
from ellar.di import injectable
163162

@@ -314,11 +313,9 @@ Let's see how we can use `TestClient` in writing e2e testing for `CarController`
314313

315314
```python
316315
# project_name/car/tests/test_controllers.py
317-
from unittest.mock import patch
318316
from ellar.di import ProviderConfig
319317
from ellar.testing import Test, TestClient
320318
from project_name.apps.car.controllers import CarController
321-
from project_name.apps.car.schemas import CreateCarSerializer, CarListFilter
322319
from project_name.apps.car.services import CarRepository
323320

324321

docs/basics/versioning.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ To enable **URL Versioning** for your application, do the following:
2121
```python
2222
# project_name/server.py
2323
import os
24-
from ellar.constants import ELLAR_CONFIG_MODULE
24+
from ellar.common.constants import ELLAR_CONFIG_MODULE
2525
from ellar.core.factory import AppFactory
2626
from ellar.core.versioning import VersioningSchemes
2727
from .root_module import ApplicationModule
@@ -55,7 +55,7 @@ To enable **Header Versioning** for your application, do the following:
5555
```python
5656
# project_name/server.py
5757
import os
58-
from ellar.constants import ELLAR_CONFIG_MODULE
58+
from ellar.common.constants import ELLAR_CONFIG_MODULE
5959
from ellar.core.factory import AppFactory
6060
from ellar.core.versioning import VersioningSchemes
6161
from .root_module import ApplicationModule
@@ -110,7 +110,7 @@ To enable **Query Versioning** for your application, do the following:
110110
```python
111111
# project_name/server.py
112112
import os
113-
from ellar.constants import ELLAR_CONFIG_MODULE
113+
from ellar.common.constants import ELLAR_CONFIG_MODULE
114114
from ellar.core.factory import AppFactory
115115
from ellar.core.versioning import VersioningSchemes
116116
from .root_module import ApplicationModule
@@ -143,7 +143,7 @@ To enable **Host Versioning** for your application, do the following:
143143
```python
144144
# project_name/server.py
145145
import os
146-
from ellar.constants import ELLAR_CONFIG_MODULE
146+
from ellar.common.constants import ELLAR_CONFIG_MODULE
147147
from ellar.core.factory import AppFactory
148148
from ellar.core.versioning import VersioningSchemes
149149
from .root_module import ApplicationModule

docs/caching.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ Here's an example of how to use a custom `make_key_callback` function with the c
457457
```python
458458
from ellar.common import get, cache
459459
from ellar.core import ExecutionContext
460-
from ellar.helper import get_name
460+
from ellar.common.helper import get_name
461461

462462
def make_key_function(ctx: ExecutionContext, key_prefix: str) -> str:
463463
function_name = get_name(ctx.get_handler())
@@ -477,7 +477,7 @@ Here's an example of how to use a custom `make_key_callback` function with the c
477477
```python
478478
from ellar.common import get, cache
479479
from ellar.core import ExecutionContext
480-
from ellar.helper import get_name
480+
from ellar.common.helper import get_name
481481

482482
def make_key_function(ctx: ExecutionContext, key_prefix: str) -> str:
483483
function_name = get_name(ctx.get_handler())

docs/configurations.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ When turned on, `injector` can automatically bind to missing types as `singleton
3232
And when turned off, missing types will raise an `UnsatisfiedRequirement` exception.
3333

3434
### **DEFAULT_JSON_CLASS**
35-
Default: `JSONResponse` - (`starlette.response.JSONResponse`)
35+
Default: `JSONResponse` - (`starlette.common.JSONResponse`)
3636

3737
**DEFAULT_JSON_CLASS** is used when sending JSON response to the client.
3838

3939
There are other options for JSON available in Ellar:
4040

41-
- **UJSONResponse**(`ellar.core.response.UJSONResponse`): renders JSON response using [ujson](https://pypi.python.org/pypi/ujson).
42-
- **ORJSONResponse**(`ellar.core.response.ORJSONResponse`): renders JSON response using [orjson](https://pypi.org/project/orjson/).
41+
- **UJSONResponse**(`ellar.common.UJSONResponse`): renders JSON response using [ujson](https://pypi.python.org/pypi/ujson).
42+
- **ORJSONResponse**(`ellar.common.ORJSONResponse`): renders JSON response using [orjson](https://pypi.org/project/orjson/).
4343

4444
### **JINJA_TEMPLATES_OPTIONS**
4545
Default: `{}`
@@ -152,10 +152,10 @@ Default: `not_found` (`not_found(scope: TScope, receive: TReceive, send: TSend)`
152152
Default is an ASGI function. **DEFAULT_NOT_FOUND_HANDLER** is used by the application router as a callback function to a resource not found.
153153

154154
```python
155-
from ellar.types import TScope, TReceive, TSend
155+
from ellar.common.types import TScope, TReceive, TSend
156156
from starlette.exceptions import HTTPException as StarletteHTTPException
157157
from starlette.websockets import WebSocketClose
158-
from ellar.core.response import PlainTextResponse
158+
from ellar.common import PlainTextResponse
159159

160160

161161
async def _not_found(scope: TScope, receive: TReceive, send: TSend) -> None:

docs/handling-response/response-model.md

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ This response model holds information on the type of response to be returned.
66
```python
77
# project_name/apps/items/controllers.py
88

9-
from ellar.core.serializer import Serializer
10-
from ellar.common import Controller, get
11-
from ellar.core import ControllerBase
9+
from ellar.common import Controller, get, Serializer, ControllerBase
1210

1311
class UserSchema(Serializer):
1412
username: str
@@ -30,8 +28,8 @@ During route response computation, the `me` route handler response will evaluate
3028
The resulting route responses will be:
3129

3230
```python
33-
from ellar.core.serializer import Serializer
34-
from ellar.core.response.model import JSONResponseModel
31+
from ellar.common import Serializer
32+
from ellar.common.responses.models import JSONResponseModel
3533

3634

3735
class UserSchema(Serializer):
@@ -73,10 +71,7 @@ For example:
7371
```python
7472
# project_name/apps/items/controllers.py
7573

76-
from ellar.common import Controller, get
77-
from ellar.core import ControllerBase
78-
from starlette.responses import PlainTextResponse
79-
from ellar.core.serializer import Serializer
74+
from ellar.common import Controller, get, ControllerBase,PlainTextResponse, Serializer
8075

8176

8277
class UserSchema(Serializer):
@@ -95,8 +90,8 @@ class ItemsController(ControllerBase):
9590
This will be translated to:
9691

9792
```python
98-
from ellar.core.response.model import ResponseModel, JSONResponseModel
99-
from starlette.responses import PlainTextResponse
93+
from ellar.common.responses.models import ResponseModel, JSONResponseModel
94+
from ellar.common import PlainTextResponse
10095

10196
response = {200: ResponseModel(response_type=PlainTextResponse), 201: JSONResponseModel(model_field_or_schema=UserSchema)}
10297
```
@@ -109,8 +104,7 @@ All response model follows `IResponseModel` contract.
109104
import typing as t
110105

111106
from pydantic.fields import ModelField
112-
from ellar.core.context import IExecutionContext
113-
from ellar.core.response import Response
107+
from ellar.common import IExecutionContext, Response
114108

115109

116110
class IResponseModel:
@@ -197,10 +191,8 @@ Lets create a new JSON response model.
197191
# project_name/apps/items/controllers.py
198192

199193
import typing as t
200-
from ellar.common import Controller, get
201-
from ellar.core import ControllerBase
202-
from ellar.core.response.model.base import ResponseModel
203-
from ellar.core.response import JSONResponse
194+
from ellar.common import Controller, get, ControllerBase, JSONResponse
195+
from ellar.common.responses.models import ResponseModel
204196
from dataclasses import dataclass
205197

206198

docs/handling-response/response.md

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ To use `Serializer` in Ellar, you simply need to create a class that inherits fr
55
Here's an example of how you could define a serializer class for a user model:
66

77
```python
8-
from ellar.core.serializer import Serializer
8+
from ellar.common import Serializer
99

1010
class UserSerializer(Serializer):
1111
name: str
@@ -27,9 +27,7 @@ For example:
2727
```python
2828
# project_name/apps/items/controllers.py
2929

30-
from ellar.core.serializer import Serializer
31-
from ellar.common import Controller, get
32-
from ellar.core import ControllerBase
30+
from ellar.common import Controller, get, Serializer, ControllerBase
3331

3432
# Define a User class with username, email, first_name, and last_name attributes
3533
class User:
@@ -80,7 +78,7 @@ For instance, we can convert the `UserSchema` to a dataclass by defining `UserDa
8078

8179
```python
8280
from dataclasses import dataclass
83-
from ellar.core.serializer import DataclassSerializer
81+
from ellar.common import DataclassSerializer
8482

8583

8684
@dataclass
@@ -101,9 +99,7 @@ The `response` parameter takes different shape. Let's see how to return a differ
10199
```python
102100
# project_name/apps/items/controllers.py
103101

104-
from ellar.core.serializer import Serializer
105-
from ellar.common import Controller, get
106-
from ellar.core import ControllerBase
102+
from ellar.common import Controller, get, ControllerBase, Serializer
107103

108104
class User:
109105
def __init__(self, username: str, email:str=None, first_name:str=None, last_name:str=None) -> None:
@@ -167,9 +163,7 @@ You can use `Response` type to change the format of data returned from endpoint
167163
```python
168164
# project_name/apps/items/controllers.py
169165

170-
from ellar.common import Controller, get
171-
from ellar.core import ControllerBase
172-
from starlette.responses import PlainTextResponse
166+
from ellar.common import Controller, get, ControllerBase, PlainTextResponse
173167

174168

175169
@Controller
@@ -185,10 +179,7 @@ Also, we can return response object from endpoint functions, and it will overrid
185179
```python
186180
# project_name/apps/items/controllers.py
187181

188-
from ellar.core.serializer import Serializer
189-
from ellar.common import Controller, get
190-
from ellar.core import ControllerBase
191-
from starlette.responses import PlainTextResponse
182+
from ellar.common import Controller, get, Serializer, ControllerBase, PlainTextResponse
192183

193184
class UserSchema(Serializer):
194185
username: str

docs/img/live_support_websocket_3.gif

119 KB
Loading

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# **[ellar](#introduction)**
12
<p align="center">
23
<a href="#" target="blank"><img src="img/EllarLogoB.png" width="200" alt="Ellar Logo" /></a>
34
</p>

0 commit comments

Comments
 (0)