Project

General

Profile

0002-utils-prevent-import-loop-31204.patch

Benjamin Dauvergne, 04 Oct 2019 02:04 AM

Download (1.93 KB)

View differences:

Subject: [PATCH 2/4] utils: prevent import loop (#31204)

 passerelle/utils/__init__.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
passerelle/utils/__init__.py
35 35
from django.contrib.contenttypes.models import ContentType
36 36
from django.db import transaction
37 37

  
38
from passerelle.base.models import ApiUser, AccessRight, BaseResource
39 38
from passerelle.base.signature import check_query, check_url
40 39

  
41 40

  
......
55 54

  
56 55

  
57 56
def get_request_users(request):
57
    from passerelle.base.models import ApiUser, BaseResource
58 58
    users = []
59 59

  
60 60
    users.extend(ApiUser.objects.filter(keytype=''))
......
118 118

  
119 119

  
120 120
def is_authorized(request, obj, perm):
121
    from passerelle.base.models import AccessRight
122

  
121 123
    if is_trusted(request):
122 124
        return True
123 125
    resource_type = ContentType.objects.get_for_model(obj)
......
271 273

  
272 274
def export_site():
273 275
    '''Dump passerelle configuration (users, resources and ACLs) to JSON dumpable dictionnary'''
276
    from passerelle.base.models import ApiUser, BaseResource
277

  
274 278
    d = {}
275 279
    d['apiusers'] = [apiuser.export_json() for apiuser in ApiUser.objects.all()]
276 280
    d['resources'] = resources = []
......
289 293
    '''Load passerelle configuration (users, resources and ACLs) from a dictionnary loaded from
290 294
       JSON
291 295
    '''
296
    from passerelle.base.models import ApiUser, BaseResource
292 297
    d = d.copy()
293 298

  
294 299
    def is_empty():
295
-