You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by tv...@apache.org on 2013/06/25 15:37:56 UTC
[1/3] git commit: [#6324] Reduce ProjectRole queries when getting
user's projects
Updated Branches:
refs/heads/master a14460891 -> e8fb5d8ce
[#6324] Reduce ProjectRole queries when getting user's projects
Signed-off-by: Cory Johns <cj...@slashdotmedia.com>
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/e8fb5d8c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/e8fb5d8c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/e8fb5d8c
Branch: refs/heads/master
Commit: e8fb5d8cebf9329c17615199794fe91b3ed1752e
Parents: 5fb91e9
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Thu Jun 20 16:07:48 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Tue Jun 25 13:37:29 2013 +0000
----------------------------------------------------------------------
Allura/allura/model/auth.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e8fb5d8c/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index 38890fc..e7f045b 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -651,8 +651,8 @@ class User(MappedClass, ActivityNode, ActivityObject):
def my_projects(self):
'''Find the projects for which this user has a named role.'''
- reaching_role_ids = g.credentials.user_roles(user_id=self._id).reaching_ids_set
- reaching_roles = [ ProjectRole.query.get(_id=i) for i in reaching_role_ids ]
+ reaching_role_ids = list(g.credentials.user_roles(user_id=self._id).reaching_ids_set)
+ reaching_roles = ProjectRole.query.find({'_id': {'$in': reaching_role_ids}}).all()
named_roles = [ r for r in reaching_roles
if r.name and r.project and not r.project.deleted ]
seen_project_ids = set()
[3/3] git commit: [#6324] Reduce unnecessary project cache clearing
on new projects
Posted by tv...@apache.org.
[#6324] Reduce unnecessary project cache clearing on new projects
Signed-off-by: Cory Johns <cj...@slashdotmedia.com>
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/e2bb7716
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/e2bb7716
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/e2bb7716
Branch: refs/heads/master
Commit: e2bb7716edfc71f1084cabe10b859e0181187252
Parents: a144608
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Wed Jun 19 18:38:06 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Tue Jun 25 13:37:29 2013 +0000
----------------------------------------------------------------------
Allura/allura/lib/plugin.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e2bb7716/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index 0d104f5..855e71c 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -576,7 +576,8 @@ class ProjectRegistrationProvider(object):
# clear the RoleCache for the user so this project will
# be picked up by user.my_projects()
- g.credentials.clear_user(user._id, '*')
+ g.credentials.clear_user(user._id, None) # unnamed roles for this user
+ g.credentials.clear_user(user._id, p._id) # named roles for this project + user
with h.push_config(c, project=p, user=user):
ThreadLocalORMSession.flush_all()
# have to add user to context, since this may occur inside auth code
[2/3] git commit: [#6324] Use index when querying for named roles
Posted by tv...@apache.org.
[#6324] Use index when querying for named roles
Signed-off-by: Cory Johns <cj...@slashdotmedia.com>
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/5fb91e9f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/5fb91e9f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/5fb91e9f
Branch: refs/heads/master
Commit: 5fb91e9f8593e16121a88275c8605f970028f896
Parents: e2bb771
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Wed Jun 19 18:42:16 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Tue Jun 25 13:37:29 2013 +0000
----------------------------------------------------------------------
Allura/allura/lib/security.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/5fb91e9f/Allura/allura/lib/security.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/security.py b/Allura/allura/lib/security.py
index 96e6b9d..21ffb0a 100644
--- a/Allura/allura/lib/security.py
+++ b/Allura/allura/lib/security.py
@@ -72,15 +72,18 @@ class Credentials(object):
if not project_ids: return
if user_id is None:
q = self.project_role.find({
+ 'user_id': None,
'project_id': {'$in': project_ids},
'name': '*anonymous'})
else:
q0 = self.project_role.find({
+ 'user_id': None,
'project_id': {'$in': project_ids},
'name': {'$in': ['*anonymous', '*authenticated']}})
q1 = self.project_role.find({
+ 'user_id': user_id,
'project_id': {'$in': project_ids},
- 'user_id': user_id})
+ 'name': None})
q = chain(q0, q1)
roles_by_project = dict((pid, []) for pid in project_ids)
for role in q: