You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2013/03/29 17:55:42 UTC
[13/14] git commit: [#5971] don't re-query the Users nbhd every time
we look up a user-project
[#5971] don't re-query the Users nbhd every time we look up a user-project
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/53635e77
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/53635e77
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/53635e77
Branch: refs/heads/cj/5978
Commit: 53635e778f61d8a8a20f0205caa45eabdbe0d143
Parents: d7846b2
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Thu Mar 28 19:12:50 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Fri Mar 29 15:23:59 2013 +0000
----------------------------------------------------------------------
Allura/allura/model/auth.py | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/53635e77/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index ee9abec..5ccfd60 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -23,6 +23,7 @@ from ming.orm import session, state
from ming.orm import FieldProperty, RelationProperty, ForeignIdProperty
from ming.orm.declarative import MappedClass
from ming.orm.ormsession import ThreadLocalORMSession
+from ming.utils import LazyProperty
import allura.tasks.mail_tasks
from allura.lib import helpers as h
@@ -583,6 +584,11 @@ class User(MappedClass, ActivityNode, ActivityObject):
user=user, user_project=True)
return user
+ @LazyProperty
+ def neighborhood(self):
+ from allura import model as M
+ return M.Neighborhood.query.get(name='Users')
+
def private_project(self):
'''
Returns the personal user-project for the user
@@ -591,7 +597,7 @@ class User(MappedClass, ActivityNode, ActivityObject):
return None
from allura import model as M
- n = M.Neighborhood.query.get(name='Users')
+ n = self.neighborhood
auth_provider = plugin.AuthenticationProvider.get(request)
project_shortname = auth_provider.user_project_shortname(self)
p = M.Project.query.get(shortname=project_shortname, neighborhood_id=n._id)