base-api-utils 1.1.117.dev2__py3-none-any.whl → 1.1.117.dev4__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 +1,11 @@
1
- from .urls import private_tasks_admin_patterns # noqa: F401
1
+ def __getattr__(name: str):
2
+ # Lazy import: loading private_tasks_admin_patterns eagerly chains through
3
+ # views → tasks_result_view → @extend_schema → DEFAULT_SCHEMA_CLASS,
4
+ # which causes a circular import when any consumer of this package is
5
+ # itself imported as DEFAULT_SCHEMA_CLASS (e.g. a custom AutoSchema
6
+ # subclass that inherits from base_api_utils.utils.CustomAutoSchema).
7
+ if name == "private_tasks_admin_patterns":
8
+ from .urls import private_tasks_admin_patterns
9
+
10
+ return private_tasks_admin_patterns
11
+ raise AttributeError(f"module 'base_api_utils' has no attribute {name!r}")
@@ -3,6 +3,7 @@ import copy
3
3
  from .expands import ExpandMapping
4
4
  from .query_params import normalize_none, parse_tree
5
5
 
6
+
6
7
  class AbstractSerializer:
7
8
  allowed_fields = None
8
9
  allowed_relations = []
@@ -126,6 +127,23 @@ class AbstractSerializer:
126
127
  ft = ctx.get("fields_tree")
127
128
  if ft is None or (isinstance(ft, dict) and len(ft) == 0):
128
129
  return fields
130
+ # Navigation-only fields_tree (every top-level key has a non-empty
131
+ # subtree pointing deeper) means the user only constrained nested
132
+ # levels and never listed a scalar at this one. Preserve defaults
133
+ # here and let the deeper constraints apply at child serializers.
134
+ has_explicit_leaf = any(not subtree for subtree in ft.values())
135
+ if not has_explicit_leaf:
136
+ af = self._merged_allowed_fields()
137
+ if af is not None:
138
+ allowed_keep = (
139
+ set(af)
140
+ | set(ctx.get("expand_tree", {}).keys())
141
+ | set(ctx.get("relations_tree", {}).keys())
142
+ )
143
+ for k in list(fields.keys()):
144
+ if k not in allowed_keep:
145
+ fields.pop(k, None)
146
+ return fields
129
147
  keep = (
130
148
  set(ft.keys())
131
149
  | set(ctx.get("expand_tree", {}).keys())
@@ -169,4 +187,5 @@ class AbstractSerializer:
169
187
  return ChildSerializer(context=self.get_child_context('field_name')).to_representation(obj)
170
188
  """
171
189
  from .expands import _child_context
172
- return _child_context(self._own_context, attr)
190
+
191
+ return _child_context(self._own_context, attr)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: base-api-utils
3
- Version: 1.1.117.dev2
3
+ Version: 1.1.117.dev4
4
4
  Summary: Django Rest Framework micro services common utilities
5
5
  Author-email: Román Gutierrez <roman@tipit.net>, Sebastian Marcet <sebastian@tipit.net>
6
6
  Project-URL: Homepage, https://github.com/fntechgit/base-api-utils
@@ -1,4 +1,4 @@
1
- base_api_utils/__init__.py,sha256=ZYiqZZU-O9G11jTGHpU2YhF2Zc5yq9iKBt4xwIE5JWg,61
1
+ base_api_utils/__init__.py,sha256=PFn18gfAlUKGuZHfRDaxsinDNj-7YDL5u_ziAX4reRQ,632
2
2
  base_api_utils/urls.py,sha256=B86B4-tZrWEGpRDYhLmExr5pQA9wKddOme0jANvwetw,443
3
3
  base_api_utils/commands/__init__.py,sha256=yVtaOu4Z6uTUSWP0JPcRmBwlGofdfvfGPXAXyrpLoO8,67
4
4
  base_api_utils/commands/failed_task_management_mixin.py,sha256=RO5krEbDdIH2tsDy-LVbAiTU9M87HsaEholA2lpvb-8,4879
@@ -44,7 +44,7 @@ base_api_utils/serializers/serializers_registry.py,sha256=V4teS5tCNQ2WdzN-tYNJSM
44
44
  base_api_utils/serializers/task_result_serializer.py,sha256=oUqD9EDQr2oxyIpgZJ1lpSGKF5Vhhy25TOQUCGTPqFY,218
45
45
  base_api_utils/serializers/timestamp_field.py,sha256=uZXbJ7BnabJylSZPt_dQEUBuT_XL3khhGjzJ08ji-DY,682
46
46
  base_api_utils/serializers/v2/__init__.py,sha256=hOWxvmFSrKpkB19x3MPz37Pz1BjJqaymqs5Dt6m4_fA,241
47
- base_api_utils/serializers/v2/abstract_serializer.py,sha256=OwRfK9VIV4Y0ybB0j8xQawM-_ac1L1q8KXGDE45i6kY,6370
47
+ base_api_utils/serializers/v2/abstract_serializer.py,sha256=lLDcjZ318lrpp575hy71Gs5Sr0BboITc6Az-jOYgo6M,7220
48
48
  base_api_utils/serializers/v2/base_model_serializer.py,sha256=S9AO0GXUcOvA6wCO88VoSSVFHBwe2fFAHZe4gmZKn6M,720
49
49
  base_api_utils/serializers/v2/expands.py,sha256=uVIAgw2eRKaL0dvJlvh3CqdQDvqvg1Iv0caH2lvIqT4,3992
50
50
  base_api_utils/serializers/v2/query_params.py,sha256=6b6rnV0Ye37xWun72x7zHKtspWzn4tdf2gVaFEaqp9M,1821
@@ -98,8 +98,8 @@ base_api_utils/views/base_view.py,sha256=A49KZr03qxjBQvCLLdtbg4s3f9Gn9C63gwcpme2
98
98
  base_api_utils/views/parent_children_crud.py,sha256=79vB044kmY9kefb6YxekPriO3FKYV85zn3PgCmSSKFw,3261
99
99
  base_api_utils/views/root_entity_crud.py,sha256=eIhZfjouNxYAVIfGPuEPp80b50hM2CAG_L0nh6-Gdjw,2830
100
100
  base_api_utils/views/tasks_result_view.py,sha256=StCfFsnpi4drUD73C_w4VLVpd546B5r8tTxB6JWoyRA,2065
101
- base_api_utils-1.1.117.dev2.dist-info/licenses/LICENSE,sha256=JKqaWBs87qnqDsZ1EEF0gnWR2iSAh92F9TJ7tqg2OwQ,547
102
- base_api_utils-1.1.117.dev2.dist-info/METADATA,sha256=Q0Rgw5QFwkR9Hvq5tXz0pnTCOLauJ-8Iw8sNR1AiXu0,2386
103
- base_api_utils-1.1.117.dev2.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
104
- base_api_utils-1.1.117.dev2.dist-info/top_level.txt,sha256=uRTtK_DlttSQ1sVajv2TKZy5XLVWawLxi2PUU-uCR7A,15
105
- base_api_utils-1.1.117.dev2.dist-info/RECORD,,
101
+ base_api_utils-1.1.117.dev4.dist-info/licenses/LICENSE,sha256=JKqaWBs87qnqDsZ1EEF0gnWR2iSAh92F9TJ7tqg2OwQ,547
102
+ base_api_utils-1.1.117.dev4.dist-info/METADATA,sha256=xw5ZCJD3OzO6hGy4nMcvMlHbblIGJ5CBgFgDHuFrU9w,2386
103
+ base_api_utils-1.1.117.dev4.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
104
+ base_api_utils-1.1.117.dev4.dist-info/top_level.txt,sha256=uRTtK_DlttSQ1sVajv2TKZy5XLVWawLxi2PUU-uCR7A,15
105
+ base_api_utils-1.1.117.dev4.dist-info/RECORD,,