Project

General

Profile

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

Benjamin Dauvergne, 14 May 2019 10:13 AM

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)
......
321 323

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

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

  
344 349
    def is_empty():
345
-