[MERGE] Django auth should not hit the DB for every group

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




--
Stephen Gallagher
RHCE 804006346421761

Delivering value year after year.
Red Hat ranks #1 in value among software vendors.
http://www.redhat.com/promo/vendor/
# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: sgallagh@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\
#   0klvnl44ynkqz771
# target_branch: bzr://bzr.fedorahosted.org/bzr/python-fedora/python-\
#   fedora-devel/
# testament_sha1: aae523a2b7bfd972df85f61d9660d359152beb33
# timestamp: 2010-04-19 15:12:10 -0400
# base_revision_id: toshio@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\
#   7mzxred8mrovqu9m
# 
# Begin patch
=== modified file 'fedora/django/auth/models.py'
--- fedora/django/auth/models.py	2010-03-15 23:22:05 +0000
+++ fedora/django/auth/models.py	2010-04-19 19:01:54 +0000
@@ -83,6 +83,19 @@
         if getattr(settings, 'FAS_GENERICEMAIL', True):
             u.email = u._get_email()
         u.save()
+        known_groups = []
+        for group in u.groups.values():
+            known_groups.append(group['id'])
+
+        fas_groups = []
+        for group in user['approved_memberships']:
+            fas_groups.append(group['id'])
+
+        # Make sure that all FAS groups are listed in Django
+        if sorted(known_groups) == sorted(fas_groups):
+          return u;
+
+        # Some groups didn't match. Update them all
         for group in user['approved_memberships']:
             g = _new_group(group)
             u.groups.add(g)

# Begin bundle
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWaHlEPUAAbpfgAVQWeP//3cC
Cgq////wUAQGvOuicd27ZerjCSUaTAJkyA0CNTbRR6anpPRPapp6QAylNoaTxTTQAyNGgAAAAAJI
iNKan6p+ymTVPSeU9NT1HkJ6mBqAPJGQMkmpkekGmjQDQeo0AGgAAAkkIYmiU/TKelNqb0p6m0mn
6oDIMQAaOESZ2yU6T17WGjLQuJA/qV8aiGULSTaX3Aa5nnGrDUJJwjrLkP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peeUgmiTLVrv9wEbVwUSZJq7ERmVcKoJU3LH
NE2aSuA70J2ksR113VkCQZFmoOqmU8vPEs/ybbdb0sj1sgald5rqvVyCQnhUy7lHVVq8fwTnNu7h
QwFPEjiv+LuSKcKEhQ8oh6g=
_______________________________________________
infrastructure mailing list
infrastructure@xxxxxxxxxxxxxxxxxxxxxxx
https://admin.fedoraproject.org/mailman/listinfo/infrastructure

[Index of Archives]     [Fedora Development]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]

  Powered by Linux