Projet

Général

Profil

0004-django-1.6-use-ATOMIC_REQUESTS-setting-instead-of-Tr.patch

Benjamin Dauvergne, 12 août 2014 14:40

Télécharger (4,44 ko)

Voir les différences:

Subject: [PATCH 4/6] [django-1.6] use ATOMIC_REQUESTS setting instead of
 TransactionMiddleware

Also remove all use of commit_on_success decorator which is useless
since all requests are atomic.

refs #5244
 authentic2/auth2_auth/auth2_ssl/backend.py  |    2 --
 authentic2/backends/ldap_backend.py         |    3 +--
 authentic2/management/commands/load-ldif.py |    4 ++--
 authentic2/saml/common.py                   |    1 -
 authentic2/settings.py                      |   12 +++++++++++-
 5 files changed, 14 insertions(+), 8 deletions(-)
authentic2/auth2_auth/auth2_ssl/backend.py
69 69
            return None
70 70

  
71 71

  
72
    @transaction.commit_on_success
73 72
    def create_user(self, ssl_info):
74 73
        """
75 74
        This method creates a new django User and ClientCertificate record
......
100 99
        self.link_user(ssl_info, user)
101 100
        return user
102 101

  
103
    @transaction.commit_on_success
104 102
    def link_user(self, ssl_info, user):
105 103
        """
106 104
        This method creates a new django User and ClientCertificate record
authentic2/backends/ldap_backend.py
31 31

  
32 32
from authentic2.cache import get_shared_cache
33 33
from authentic2.decorators import to_list
34
from authentic2.compat import get_user_model, commit_on_success
34
from authentic2.compat import get_user_model
35 35
from authentic2.models import UserExternalId
36 36

  
37 37

  
......
701 701
                        .filter(user=user, source=block['realm']) \
702 702
                        .delete()
703 703

  
704
    @commit_on_success
705 704
    def _return_user(self, uri, dn, username, password, conn, block):
706 705
        attributes = self.get_ldap_attributes(block, conn, dn)
707 706
        if attributes is None:
authentic2/management/commands/load-ldif.py
4 4

  
5 5

  
6 6
from django.core.management.base import BaseCommand, CommandError
7
from django.db import transaction
8 7
from django.contrib.auth import get_user_model
9 8

  
10 9

  
10
from authentic2.compat import atomic
11 11
from authentic2.hashers import olap_password_to_dj
12 12
from authentic2.models import Attribute
13 13

  
......
136 136
    args = '<ldif_file...>'
137 137
    help = 'Load/update LDIF files as users'
138 138

  
139
    @transaction.commit_on_success
139
    @atomic
140 140
    def handle(self, *args, **options):
141 141
        options['verbosity'] = int(options['verbosity'])
142 142
        for arg in args:
authentic2/saml/common.py
311 311
    d = LibertyManageDump.objects.filter(django_session_key = request.session.session_key)
312 312
    return d
313 313

  
314
@transaction.commit_on_success
315 314
def retrieve_metadata_and_create(request, provider_id, sp_or_idp):
316 315
    logger.debug('trying to load %s from wkl' % provider_id)
317 316
    if not provider_id.startswith('http'):
authentic2/settings.py
4 4
import glob
5 5
import re
6 6

  
7
import django
7 8
from django.core.exceptions import ImproperlyConfigured
8 9
from django.conf import global_settings
9 10

  
......
118 119
    'django.middleware.locale.LocaleMiddleware',
119 120
    'django.contrib.auth.middleware.AuthenticationMiddleware',
120 121
    'django.contrib.messages.middleware.MessageMiddleware',
121
    'django.middleware.transaction.TransactionMiddleware',
122
)
123

  
124
if django.VERSION < (1, 6, 0):
125
    MIDDLEWARE_CLASSES += (
126
        'django.middleware.transaction.TransactionMiddleware',
127
    )
128
else:
129
    ATOMIC_REQUESTS = True
130

  
131
MIDDLEWARE_CLASSES += (
122 132
    'authentic2.idp.middleware.DebugMiddleware',
123 133
    'authentic2.middleware.CollectIPMiddleware',
124 134
)
125
-