Fast-Controller 0.5.1b0__tar.gz → 0.6.1__tar.gz

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,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: Fast-Controller
3
- Version: 0.5.1b0
3
+ Version: 0.6.1
4
4
  Summary: The fastest way to a turn your models into a full ReST API
5
5
  Keywords: controller,base,rest,api,backend
6
6
  Author-Email: Cody M Sommer <bassmastacod@gmail.com>
@@ -184,7 +184,8 @@ def _register_delete_endpoint(controller, router: APIRouter, resource: type[Reso
184
184
  @docstring_format(resource=inflect.a(resource.doc_name()))
185
185
  def delete(daos: DAOFactory = controller.daos, **kwargs) -> None:
186
186
  """Deletes {resource}"""
187
- daos[resource].remove(*extract_values(kwargs, pk))
187
+ model = daos[resource].get(*extract_values(kwargs, pk))
188
+ daos[resource].remove(model)
188
189
 
189
190
  expose_path_params(delete, pk)
190
191
 
@@ -208,11 +209,11 @@ def _register_rename_endpoint(controller, router: APIRouter, resource: type[Reso
208
209
 
209
210
  if len(pk) == 1:
210
211
  new_value = kwargs['new_pk']
211
- dao.rename(current, dao.get(new_value))
212
+ dao.rename(current, new_value)
212
213
  else:
213
214
  new_values = kwargs.get('new_pk', {})
214
215
  new_pk_values = [new_values.get(field, kwargs[field]) for field in pk]
215
- dao.rename(current, dao.get(*new_pk_values))
216
+ dao.rename(current, *new_pk_values)
216
217
 
217
218
  return current
218
219
 
@@ -290,10 +291,10 @@ class Controller:
290
291
  resource_router = APIRouter(
291
292
  prefix=resource.get_resource_path(),
292
293
  tags=[resource.resource_name()])
293
- self._register_resource_endpoints(resource_router, resource, skip)
294
294
 
295
295
  if additional_endpoints:
296
296
  additional_endpoints(resource_router, self)
297
+ self._register_resource_endpoints(resource_router, resource, skip)
297
298
 
298
299
  self.router.include_router(resource_router)
299
300
 
@@ -1,7 +1,6 @@
1
1
  import inspect
2
2
  from functools import wraps
3
3
  from typing import Callable, get_type_hints
4
- from warnings import deprecated
5
4
 
6
5
  import inflect as _inflect
7
6
  from daomodel.search_util import *
@@ -30,21 +29,6 @@ def docstring_format(**kwargs):
30
29
  return decorator
31
30
 
32
31
 
33
- @deprecated("No usages and no test coverage")
34
- def all_optional(superclass: type[SQLModel]):
35
- """Creates a new SQLModel for the specified class but having no required fields.
36
-
37
- :param superclass: The SQLModel of which to make all fields Optional
38
- :return: The newly wrapped Model
39
- """
40
- class OptionalModel(superclass):
41
- pass
42
- for field, field_type in get_type_hints(OptionalModel).items():
43
- if not isinstance(field_type, type(Optional)):
44
- OptionalModel.__annotations__[field] = Optional[field_type]
45
- return OptionalModel
46
-
47
-
48
32
  def expose_path_params(func: Callable, field_names: list[str]) -> Callable:
49
33
  """Converts implicit path parameters from **kwargs to explicit parameters.
50
34
 
@@ -39,7 +39,7 @@ classifiers = [
39
39
  "Topic :: Software Development :: Libraries",
40
40
  "Typing :: Typed",
41
41
  ]
42
- version = "0.5.1b0"
42
+ version = "0.6.1"
43
43
 
44
44
  [project.license]
45
45
  text = "MIT"
@@ -19,14 +19,14 @@ class Default(SQLModel):
19
19
  pass
20
20
 
21
21
 
22
- @pytest.mark.parametrize("preferred, default, expected", [
22
+ @pytest.mark.parametrize('preferred, default, expected', [
23
23
  (Preferred, Default, Preferred),
24
24
  (SQLModel, Default, SQLModel),
25
25
  (DAOModel, Default, DAOModel),
26
26
  (Resource, Default, Resource),
27
27
  (None, Default, Default),
28
28
  (1, Default, Default),
29
- ("test", Default, Default),
29
+ ('test', Default, Default),
30
30
  (Controller, Default, Default)
31
31
  ])
32
32
  def test_either(preferred: Any, default: type[SQLModel], expected: type[SQLModel]):
@@ -36,7 +36,7 @@ def test_either(preferred: Any, default: type[SQLModel], expected: type[SQLModel
36
36
  def test_get_path():
37
37
  class Class(Resource):
38
38
  pass
39
- assert Class.get_resource_path() == "/api/classes"
39
+ assert Class.get_resource_path() == '/classes'
40
40
 
41
41
 
42
42
  class Author(Resource, table=True):