You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2013/03/28 20:17:55 UTC
[2/2] 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/56c54671
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/56c54671
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/56c54671
Branch: refs/heads/db/5971
Commit: 56c54671b529bcc523f987078415b02321657604
Parents: 9ea4b5d
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Thu Mar 28 19:12:50 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Mar 28 19:12:57 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/56c54671/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)