Project

General

Profile

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

Benjamin Dauvergne, 20 Mar 2019 10:20 PM

Download (2.2 KB)

View differences:

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

 passerelle/utils/__init__.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
passerelle/utils/__init__.py
39 39
from zeep.cache import InMemoryCache
40 40
from zeep.transports import Transport
41 41

  
42
from passerelle.base.context_processors import template_vars
43
from passerelle.base.models import ApiUser, AccessRight, BaseResource
44 42
from passerelle.base.signature import check_query, check_url
45 43

  
46 44

  
......
49 47
    returns the template vars as dict, to be used in apps code
50 48
    """
51 49
    from django.http import HttpRequest
50
    from passerelle.base.context_processors import template_vars
52 51
    return template_vars(HttpRequest())
53 52

  
54 53

  
......
76 75

  
77 76

  
78 77
def get_request_users(request):
78
    from passerelle.base.models import ApiUser, BaseResource
79 79
    users = []
80 80

  
81 81
    users.extend(ApiUser.objects.filter(keytype=''))
......
139 139

  
140 140

  
141 141
def is_authorized(request, obj, perm):
142
    from passerelle.base.models import AccessRight
143

  
142 144
    if is_trusted(request):
143 145
        return True
144 146
    resource_type = ContentType.objects.get_for_model(obj)
......
319 321

  
320 322
def export_site():
321 323
    '''Dump passerelle configuration (users, resources and ACLs) to JSON dumpable dictionnary'''
324
    from passerelle.base.models import ApiUser, BaseResource
325

  
322 326
    d = {}
323 327
    d['apiusers'] = [apiuser.export_json() for apiuser in ApiUser.objects.all()]
324 328
    d['resources'] = resources = []
......
337 341
    '''Load passerelle configuration (users, resources and ACLs) from a dictionnary loaded from
338 342
       JSON
339 343
    '''
344
    from passerelle.base.models import ApiUser, BaseResource
340 345
    d = d.copy()
341 346

  
342 347
    def is_empty():
343
-