maquinaweb-shared-auth 0.2.29__py3-none-any.whl → 0.2.30__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.

Potentially problematic release.


This version of maquinaweb-shared-auth might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maquinaweb-shared-auth
3
- Version: 0.2.29
3
+ Version: 0.2.30
4
4
  Summary: Models read-only para autenticação compartilhada entre projetos Django.
5
5
  Author-email: Seu Nome <seuemail@dominio.com>
6
6
  License: MIT
@@ -5,9 +5,9 @@ shared_auth/conf.py,sha256=WlSXQB7p3BfE3BL6WR6EDYpCHQEjDlxQlyf8dTfClsk,621
5
5
  shared_auth/decorators.py,sha256=RT-Qfi7oGBo6PvWJRR1dqJUQdU6ZOf9p-8mV3rZmqQ0,3237
6
6
  shared_auth/exceptions.py,sha256=VKamHjBl2yjXG2RsMrLrXru1_Q9IJXmy4xmDcXlpWsU,627
7
7
  shared_auth/fields.py,sha256=RAcmFh1D_nkbai_7t_OrPZhfhAipesy5kKnEj4LUvvM,1254
8
- shared_auth/managers.py,sha256=WB0tU3asVxwS4tFq2R9-zXtWMBpvOuM94_SehGbVQFw,8268
8
+ shared_auth/managers.py,sha256=A9y-X4ixVXhsNxgr3YD4DtuN4ufrX7LbM_JPwJ0Y3aA,9176
9
9
  shared_auth/middleware.py,sha256=72GF8kGijbhw98v2Q-1sXBXk-7Bamfyvypm9h8xLX_I,6112
10
- shared_auth/mixins.py,sha256=BSYNTWYjLRGuxfy7x-uAaNZmrTMsm67ogAQzjrU2DoQ,7388
10
+ shared_auth/mixins.py,sha256=9TJk07hlHXnTYu0tPNr7VAXd7VL9fyXayMaFERifLLY,7389
11
11
  shared_auth/models.py,sha256=vCyssDwKfWRE3ofl6LK_CB1-y5O-_6uvJyGZGoCnb44,6574
12
12
  shared_auth/permissions.py,sha256=FNIp12ePOUlXVp26zNMAyEtzX9kwyP7RuNIgaaCXtPA,2671
13
13
  shared_auth/router.py,sha256=zYidJ7j40lQLrhkCtAQAp-rQLhua_UF0X7SDzYRcV5w,668
@@ -15,7 +15,7 @@ shared_auth/serializers.py,sha256=VmajFqnAHB5wyxsdd5_WVegAQygi0KNOMk7vScCPHiQ,73
15
15
  shared_auth/storage_backend.py,sha256=Eqkjz8aF5UrOpRwYl-J0Td95IObfxnJ8eLQDJVFM3Io,184
16
16
  shared_auth/urls.py,sha256=591wWEWJPaHEGkcOZ8yvfgxddRyOcZLgOc0vNtF7XRI,289
17
17
  shared_auth/views.py,sha256=2hyLnYSWUscfq-jVcskt-ukzDt4vg6IXeKjRDRu9RXk,1519
18
- maquinaweb_shared_auth-0.2.29.dist-info/METADATA,sha256=0zltusF9fsm1p4ldeM4su1hxpCactgoNbIFQZhDQEJM,26331
19
- maquinaweb_shared_auth-0.2.29.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
20
- maquinaweb_shared_auth-0.2.29.dist-info/top_level.txt,sha256=msyYRy02ZV7zz7GR1raUI5LXGFIFn2TIkgkeKZqKufE,12
21
- maquinaweb_shared_auth-0.2.29.dist-info/RECORD,,
18
+ maquinaweb_shared_auth-0.2.30.dist-info/METADATA,sha256=bIuaOJDn7kPoK8tE16uQWf3qgqPO3RixJpJ9HiYYXUk,26331
19
+ maquinaweb_shared_auth-0.2.30.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
20
+ maquinaweb_shared_auth-0.2.30.dist-info/top_level.txt,sha256=msyYRy02ZV7zz7GR1raUI5LXGFIFn2TIkgkeKZqKufE,12
21
+ maquinaweb_shared_auth-0.2.30.dist-info/RECORD,,
shared_auth/managers.py CHANGED
@@ -94,6 +94,9 @@ class OrganizationQuerySetMixin:
94
94
  Faz uma única query bulk para buscar todas as organizações necessárias
95
95
  e cacheia nos objetos usando _cached_organization.
96
96
 
97
+ IMPORTANTE: Este método força a avaliação do QuerySet e aplica cache.
98
+ Para manter a chain de QuerySet, chame este método por último.
99
+
97
100
  Usage:
98
101
  # Sem otimização (N+1 queries)
99
102
  rascunhos = Rascunho.objects.all()
@@ -106,13 +109,18 @@ class OrganizationQuerySetMixin:
106
109
  print(r.organization.name) # Usa cache, sem queries extras
107
110
 
108
111
  Returns:
109
- Lista de objetos com _cached_organization
112
+ Self (QuerySet) com _prefetch_done=True e objetos cacheados
110
113
  """
111
- objects = list(self.all())
112
- from .models import SharedOrganization
114
+ # Marcar que o prefetch foi feito
115
+ self._prefetch_done = True
116
+
117
+ # Forçar avaliação do queryset
118
+ objects = list(self)
113
119
 
114
120
  if not objects:
115
- return objects
121
+ return self
122
+
123
+ from .models import SharedOrganization
116
124
 
117
125
  # Coletar IDs únicos
118
126
  org_ids = set(obj.organization_id for obj in objects)
@@ -126,7 +134,10 @@ class OrganizationQuerySetMixin:
126
134
  for obj in objects:
127
135
  obj._cached_organization = organizations.get(obj.organization_id)
128
136
 
129
- return objects
137
+ # Armazenar os objetos cacheados no queryset
138
+ self._result_cache = objects
139
+
140
+ return self
130
141
 
131
142
 
132
143
  class UserQuerySetMixin:
@@ -149,13 +160,20 @@ class UserQuerySetMixin:
149
160
  rascunhos = Rascunho.objects.all().with_user_data()
150
161
  for r in rascunhos:
151
162
  print(r.user.email) # Usa cache, sem queries extras
163
+
164
+ Returns:
165
+ Self (QuerySet) com objetos cacheados
152
166
  """
153
167
  from .models import User
154
168
 
155
- objects = list(self.all())
169
+ # Marcar que o prefetch foi feito
170
+ self._prefetch_done = True
171
+
172
+ # Forçar avaliação do queryset
173
+ objects = list(self)
156
174
 
157
175
  if not objects:
158
- return objects
176
+ return self
159
177
 
160
178
  user_ids = set(obj.user_id for obj in objects)
161
179
 
@@ -164,7 +182,10 @@ class UserQuerySetMixin:
164
182
  for obj in objects:
165
183
  obj._cached_user = users.get(obj.user_id)
166
184
 
167
- return objects
185
+ # Armazenar os objetos cacheados no queryset
186
+ self._result_cache = objects
187
+
188
+ return self
168
189
 
169
190
 
170
191
  class OrganizationUserQuerySetMixin(OrganizationQuerySetMixin, UserQuerySetMixin):
@@ -191,13 +212,20 @@ class OrganizationUserQuerySetMixin(OrganizationQuerySetMixin, UserQuerySetMixin
191
212
  for r in rascunhos:
192
213
  print(r.organization.name) # Cache
193
214
  print(r.user.email) # Cache
215
+
216
+ Returns:
217
+ Self (QuerySet) com objetos cacheados
194
218
  """
195
219
  from .models import SharedOrganization, User
196
220
 
197
- objects = list(self.all())
221
+ # Marcar que o prefetch foi feito
222
+ self._prefetch_done = True
223
+
224
+ # Forçar avaliação do queryset
225
+ objects = list(self)
198
226
 
199
227
  if not objects:
200
- return objects
228
+ return self
201
229
 
202
230
  # Coletar IDs
203
231
  org_ids = set(obj.organization_id for obj in objects)
@@ -215,7 +243,10 @@ class OrganizationUserQuerySetMixin(OrganizationQuerySetMixin, UserQuerySetMixin
215
243
  obj._cached_organization = organizations.get(obj.organization_id)
216
244
  obj._cached_user = users.get(obj.user_id)
217
245
 
218
- return objects
246
+ # Armazenar os objetos cacheados no queryset
247
+ self._result_cache = objects
248
+
249
+ return self
219
250
 
220
251
  def create_with_validation(self, organization_id, user_id, **kwargs):
221
252
  """
shared_auth/mixins.py CHANGED
@@ -227,6 +227,7 @@ class LoggedOrganizationMixin(viewsets.ModelViewSet):
227
227
  return queryset.none()
228
228
 
229
229
  organization_id = self.get_organization_id()
230
+
230
231
  if hasattr(queryset.model, "organization_id"):
231
232
  return queryset.filter(organization_id=organization_id)
232
233
  elif hasattr(queryset.model, "organization"):