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/10/01 22:42:16 UTC

[1/6] git commit: [#6431] ticket:430 Upgrade to ming 0.4.x to avoid extraneous count() queries

Updated Branches:
  refs/heads/master 182a724a2 -> 30f5d75fe


[#6431] ticket:430 Upgrade to ming 0.4.x to avoid extraneous count() queries


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/f55c8bde
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/f55c8bde
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/f55c8bde

Branch: refs/heads/master
Commit: f55c8bde7af0ee01b319a145060574304e26be31
Parents: 182a724
Author: Yuriy Arhipov <yu...@yandex.ru>
Authored: Sun Sep 22 13:21:07 2013 +0400
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Tue Oct 1 20:40:40 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/auth.py                         | 2 +-
 Allura/allura/controllers/project.py                      | 6 +++---
 Allura/allura/controllers/trovecategories.py              | 2 +-
 Allura/allura/ext/admin/templates/project_tools.html      | 2 +-
 Allura/allura/model/artifact.py                           | 2 +-
 Allura/allura/templates/widgets/moderate_posts.html       | 2 +-
 ForgeTracker/forgetracker/templates/tracker/ticket.html   | 2 +-
 ForgeTracker/forgetracker/tests/unit/test_ticket_model.py | 4 ++--
 requirements-common.txt                                   | 2 +-
 9 files changed, 12 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/f55c8bde/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index fa00208..50b550f 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -511,7 +511,7 @@ class UserSkillsController(BaseController):
             selected_skill = selected_skill,
             parents = parents,
             menu = menu,
-            add_details_fields=(len(l)==0))
+            add_details_fields=(l.count() == 0))
 
     @expose()
     @require_post()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/f55c8bde/Allura/allura/controllers/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/project.py b/Allura/allura/controllers/project.py
index e2c7ee8..a1a952c 100644
--- a/Allura/allura/controllers/project.py
+++ b/Allura/allura/controllers/project.py
@@ -537,7 +537,7 @@ class NeighborhoodAdminController(object):
         awards = M.Award.query.find(dict(created_by_neighborhood_id=self.neighborhood._id)).all()
         awards_count = len(awards)
         grants = M.AwardGrant.query.find(dict(granted_by_neighborhood_id=self.neighborhood._id))
-        grants_count = len(grants)
+        grants_count = grants.count()
         c.project_select = W.project_select(self.neighborhood.url() + '_admin/project_search')
         return dict(
             awards=awards,
@@ -756,7 +756,7 @@ class NeighborhoodAwardsController(object):
     def index(self, **kw):
         require_access(self.neighborhood, 'admin')
         awards = M.Award.query.find(dict(created_by_neighborhood_id=self.neighborhood._id))
-        count = len(awards)
+        count = awards.count()
         return dict(awards=awards or [], count=count)
 
     @expose('jinja:allura:templates/award_not_found.html')
@@ -767,7 +767,7 @@ class NeighborhoodAwardsController(object):
     def grants(self, **kw):
         require_access(self.neighborhood, 'admin')
         grants = M.AwardGrant.query.find(dict(granted_by_neighborhood_id=self.neighborhood._id))
-        count = len(grants)
+        count = grants.count()
         return dict(grants=grants or [], count=count)
 
     @expose()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/f55c8bde/Allura/allura/controllers/trovecategories.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/trovecategories.py b/Allura/allura/controllers/trovecategories.py
index 79cb88c..86d4738 100644
--- a/Allura/allura/controllers/trovecategories.py
+++ b/Allura/allura/controllers/trovecategories.py
@@ -59,7 +59,7 @@ class TroveCategoryController(BaseController):
                hierarchy = [temp_cat] + hierarchy
                temp_cat = temp_cat.parent_category
         else:
-            l = M.TroveCategory.query.find(dict(trove_parent_id=0))
+            l = M.TroveCategory.query.find(dict(trove_parent_id=0)).all()
             selected_cat = None
             hierarchy = []
         return dict(

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/f55c8bde/Allura/allura/ext/admin/templates/project_tools.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/templates/project_tools.html b/Allura/allura/ext/admin/templates/project_tools.html
index 36f98f5..78fb8f1 100644
--- a/Allura/allura/ext/admin/templates/project_tools.html
+++ b/Allura/allura/ext/admin/templates/project_tools.html
@@ -44,7 +44,7 @@
     </span>
   </div>
   <form method="post" action="update_mounts" id="install_form" style="display:none">
-    <input type="hidden" name="new.ordinal" value="{{installable_tools|length + c.project.direct_subprojects|length}}"/>
+    <input type="hidden" name="new.ordinal" value="{{installable_tools|length + c.project.direct_subprojects.count()}}"/>
     <input type="hidden" name="new.ep_name" class="new_ep_name">
     <label class="grid-13">Label</label>
     <div class="grid-13"><input type="text" name="new.mount_label" class="new_mount_label"></div>

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/f55c8bde/Allura/allura/model/artifact.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/artifact.py b/Allura/allura/model/artifact.py
index 2804a17..8753f1e 100644
--- a/Allura/allura/model/artifact.py
+++ b/Allura/allura/model/artifact.py
@@ -540,7 +540,7 @@ class VersionedArtifact(Artifact):
     @property
     def last_updated(self):
         history = self.history()
-        if len(history):
+        if history.count():
             return self.history().first().timestamp
         else:
             return self.mod_date

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/f55c8bde/Allura/allura/templates/widgets/moderate_posts.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/moderate_posts.html b/Allura/allura/templates/widgets/moderate_posts.html
index 25294a3..e243b9a 100644
--- a/Allura/allura/templates/widgets/moderate_posts.html
+++ b/Allura/allura/templates/widgets/moderate_posts.html
@@ -53,7 +53,7 @@
           <td>{{author.display_name}} ({{author.username}})</td>
           <td>{{post.thread.subject or '(no subject)'}}</td>
           <td>{{h.text.truncate(post.text,200)}}</td>
-          <td>{{post.attachments|length}}</td>
+          <td>{{post.attachments.count()}}</td>
           <td>
           {% if c.app.config.tool_name.lower() != 'discussion' %}
             <a href="{{post.thread.artifact.url()}}">[{{post.thread.artifact.shorthand_id()}}]</a>

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/f55c8bde/ForgeTracker/forgetracker/templates/tracker/ticket.html
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/templates/tracker/ticket.html b/ForgeTracker/forgetracker/templates/tracker/ticket.html
index f6288bb..f780736 100644
--- a/ForgeTracker/forgetracker/templates/tracker/ticket.html
+++ b/ForgeTracker/forgetracker/templates/tracker/ticket.html
@@ -144,7 +144,7 @@
 <div id="ticket_content">
   {{g.markdown.convert(ticket.description)|safe}}
   {% if ticket.attachments %}
-    <strong class="grid-18">{{ticket.attachments.__len__()}} Attachments</strong>
+    <strong class="grid-18">{{ticket.attachments.count()}} Attachments</strong>
     <div class="clear">
     {% for att in ticket.attachments %}
         <div class="attachment_thumb">

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/f55c8bde/ForgeTracker/forgetracker/tests/unit/test_ticket_model.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/unit/test_ticket_model.py b/ForgeTracker/forgetracker/tests/unit/test_ticket_model.py
index 7f7fdd7..620abcf 100644
--- a/ForgeTracker/forgetracker/tests/unit/test_ticket_model.py
+++ b/ForgeTracker/forgetracker/tests/unit/test_ticket_model.py
@@ -270,12 +270,12 @@ class TestTicketModel(TrackerTestWithModel):
             ticket = Ticket.new()
             ticket.summary = 'test ticket'
             ticket.description = 'test description'
-        assert_equal(len(ticket.attachments), 0)
+        assert_equal(ticket.attachments.count(), 0)
         f = urllib2.urlopen('file://%s' % __file__)
         TicketAttachment.save_attachment('test_ticket_model.py', ResettableStream(f),
                                             artifact_id=ticket._id)
         ThreadLocalORMSession.flush_all()
-        assert_equal(len(ticket.attachments), 1)
+        assert_equal(ticket.attachments.count(), 1)
         assert_equal(ticket.attachments.first().filename, 'test_ticket_model.py')
 
     def test_json_parents(self):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/f55c8bde/requirements-common.txt
----------------------------------------------------------------------
diff --git a/requirements-common.txt b/requirements-common.txt
index 42bdadb..51c7636 100644
--- a/requirements-common.txt
+++ b/requirements-common.txt
@@ -21,7 +21,7 @@ httplib2==0.7.4
 iso8601==0.1.4
 Jinja2==2.6
 Markdown==2.2.0
-Ming==0.3.10
+Ming==0.4.1
 oauth2==1.5.170
 # tg2 dep PasteDeploy must specified before TurboGears2, to avoid a version/allow-hosts problem
 Paste==1.7.5.1


[3/6] git commit: [#6431] ticket:430 Fix possible count() call on list

Posted by br...@apache.org.
[#6431] ticket:430 Fix possible count() call on list


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/9d0d9968
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/9d0d9968
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/9d0d9968

Branch: refs/heads/master
Commit: 9d0d9968d63a7f0e976a578413ffa5ac8c9b1203
Parents: f55c8bd
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Sep 23 15:42:06 2013 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Tue Oct 1 20:40:41 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/auth.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9d0d9968/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 50b550f..6562d6e 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -495,7 +495,7 @@ class UserSkillsController(BaseController):
         elif self.category:
             selected_skill = self.category
         else:
-            l = M.TroveCategory.query.find(dict(trove_parent_id=0, show_as_skill=True))
+            l = M.TroveCategory.query.find(dict(trove_parent_id=0, show_as_skill=True)).all()
             selected_skill = None
         if selected_skill:
             l = [scat for scat in selected_skill.subcategories
@@ -511,7 +511,7 @@ class UserSkillsController(BaseController):
             selected_skill = selected_skill,
             parents = parents,
             menu = menu,
-            add_details_fields=(l.count() == 0))
+            add_details_fields=(len(l) == 0))
 
     @expose()
     @require_post()


[4/6] git commit: [#6431] Fix places that were still expecting a cursor

Posted by br...@apache.org.
[#6431] Fix places that were still expecting a cursor

Signed-off-by: Tim Van Steenburgh <tv...@gmail.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/128a4ddf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/128a4ddf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/128a4ddf

Branch: refs/heads/master
Commit: 128a4ddf57a697616bea150f38596d99f28ac29a
Parents: 44963d1
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Thu Sep 26 16:46:20 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Tue Oct 1 20:40:42 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/auth.py                         | 2 +-
 ForgeTracker/forgetracker/tests/unit/test_ticket_model.py | 8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/128a4ddf/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 6562d6e..ae08146 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -266,7 +266,7 @@ class AuthController(BaseController):
 
         repos = []
         for p in user.my_projects():
-            for p in [p] + p.direct_subprojects.all():
+            for p in [p] + p.direct_subprojects:
                 for app in p.app_configs:
                     if not issubclass(g.entry_points["tool"][app.tool_name], RepositoryApp):
                         continue

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/128a4ddf/ForgeTracker/forgetracker/tests/unit/test_ticket_model.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/unit/test_ticket_model.py b/ForgeTracker/forgetracker/tests/unit/test_ticket_model.py
index 93450d1..90eba99 100644
--- a/ForgeTracker/forgetracker/tests/unit/test_ticket_model.py
+++ b/ForgeTracker/forgetracker/tests/unit/test_ticket_model.py
@@ -20,6 +20,7 @@ from datetime import datetime
 import urllib2
 
 from ming.orm.ormsession import ThreadLocalORMSession
+from ming.orm import session
 from ming import schema
 from nose.tools import raises, assert_raises, assert_equal, assert_in
 
@@ -275,8 +276,11 @@ class TestTicketModel(TrackerTestWithModel):
         TicketAttachment.save_attachment('test_ticket_model.py', ResettableStream(f),
                                             artifact_id=ticket._id)
         ThreadLocalORMSession.flush_all()
-        assert_equal(ticket.attachments.count(), 1)
-        assert_equal(ticket.attachments.first().filename, 'test_ticket_model.py')
+        # need to refetch since attachments are cached
+        session(ticket).expunge(ticket)
+        ticket = Ticket.query.get(_id=ticket._id)
+        assert_equal(len(ticket.attachments), 1)
+        assert_equal(ticket.attachments[0].filename, 'test_ticket_model.py')
 
     def test_json_parents(self):
         ticket = Ticket.new()


[5/6] git commit: [#6431] bump ming version to get aggregate() method

Posted by br...@apache.org.
[#6431] bump ming version to get aggregate() method


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/f76bf432
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/f76bf432
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/f76bf432

Branch: refs/heads/master
Commit: f76bf432df6034fe537a8b0bf1aa20abdafa8ecd
Parents: 128a4dd
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Sep 27 15:18:55 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Tue Oct 1 20:40:42 2013 +0000

----------------------------------------------------------------------
 requirements-common.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/f76bf432/requirements-common.txt
----------------------------------------------------------------------
diff --git a/requirements-common.txt b/requirements-common.txt
index 51c7636..e99b5e9 100644
--- a/requirements-common.txt
+++ b/requirements-common.txt
@@ -21,7 +21,7 @@ httplib2==0.7.4
 iso8601==0.1.4
 Jinja2==2.6
 Markdown==2.2.0
-Ming==0.4.1
+Ming==0.4.2
 oauth2==1.5.170
 # tg2 dep PasteDeploy must specified before TurboGears2, to avoid a version/allow-hosts problem
 Paste==1.7.5.1


[2/6] git commit: [#6431] don't rely on bool(cursor)

Posted by br...@apache.org.
[#6431] don't rely on bool(cursor)

* bool(cursor) is not good either
* refactor some attachment methods up to (Versioned)Artifact
* User.withskill len fix


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/44963d16
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/44963d16
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/44963d16

Branch: refs/heads/master
Commit: 44963d16324b0dc4668bc40f34569bb6a5a22b78
Parents: 9d0d996
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Wed Sep 25 16:45:40 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Tue Oct 1 20:40:41 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/project.py                    |  5 ++---
 Allura/allura/controllers/trovecategories.py            |  2 +-
 Allura/allura/ext/admin/templates/project_tools.html    |  2 +-
 Allura/allura/model/artifact.py                         | 12 ++++++++++++
 Allura/allura/model/discuss.py                          |  4 ++--
 Allura/allura/model/project.py                          |  2 +-
 Allura/allura/templates/widgets/moderate_posts.html     |  2 +-
 Allura/allura/tests/model/test_discussion.py            | 10 +++++-----
 Allura/allura/tests/model/test_project.py               |  2 +-
 ForgeBlog/forgeblog/model/blog.py                       |  7 -------
 .../tests/google/functional/test_tracker.py             |  2 +-
 ForgeTracker/forgetracker/model/ticket.py               |  5 -----
 ForgeTracker/forgetracker/templates/tracker/ticket.html |  2 +-
 ForgeTracker/forgetracker/tests/functional/test_root.py |  2 +-
 .../forgetracker/tests/unit/test_ticket_model.py        |  2 +-
 ForgeWiki/forgewiki/model/wiki.py                       |  8 --------
 ForgeWiki/forgewiki/tests/functional/test_root.py       |  2 +-
 17 files changed, 31 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/44963d16/Allura/allura/controllers/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/project.py b/Allura/allura/controllers/project.py
index a1a952c..e36e52e 100644
--- a/Allura/allura/controllers/project.py
+++ b/Allura/allura/controllers/project.py
@@ -755,9 +755,8 @@ class NeighborhoodAwardsController(object):
     @expose('jinja:allura:templates/awards.html')
     def index(self, **kw):
         require_access(self.neighborhood, 'admin')
-        awards = M.Award.query.find(dict(created_by_neighborhood_id=self.neighborhood._id))
-        count = awards.count()
-        return dict(awards=awards or [], count=count)
+        awards = M.Award.query.find(dict(created_by_neighborhood_id=self.neighborhood._id)).all()
+        return dict(awards=awards or [], count=len(awards))
 
     @expose('jinja:allura:templates/award_not_found.html')
     def not_found(self, **kw):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/44963d16/Allura/allura/controllers/trovecategories.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/trovecategories.py b/Allura/allura/controllers/trovecategories.py
index 86d4738..9af28c5 100644
--- a/Allura/allura/controllers/trovecategories.py
+++ b/Allura/allura/controllers/trovecategories.py
@@ -132,7 +132,7 @@ class TroveCategoryController(BaseController):
             redirect(redirecturl)
             return
         
-        if len(M.User.withskill(cat)) > 0:
+        if M.User.withskill(cat).count() > 0:
             m = "This category is used as a skill by at least a user, "
             m = m + "therefore it can't be removed."
             flash(m, "error")

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/44963d16/Allura/allura/ext/admin/templates/project_tools.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/templates/project_tools.html b/Allura/allura/ext/admin/templates/project_tools.html
index 78fb8f1..36f98f5 100644
--- a/Allura/allura/ext/admin/templates/project_tools.html
+++ b/Allura/allura/ext/admin/templates/project_tools.html
@@ -44,7 +44,7 @@
     </span>
   </div>
   <form method="post" action="update_mounts" id="install_form" style="display:none">
-    <input type="hidden" name="new.ordinal" value="{{installable_tools|length + c.project.direct_subprojects.count()}}"/>
+    <input type="hidden" name="new.ordinal" value="{{installable_tools|length + c.project.direct_subprojects|length}}"/>
     <input type="hidden" name="new.ep_name" class="new_ep_name">
     <label class="grid-13">Label</label>
     <div class="grid-13"><input type="text" name="new.mount_label" class="new_mount_label"></div>

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/44963d16/Allura/allura/model/artifact.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/artifact.py b/Allura/allura/model/artifact.py
index 8753f1e..733f2b0 100644
--- a/Allura/allura/model/artifact.py
+++ b/Allura/allura/model/artifact.py
@@ -409,6 +409,11 @@ class Artifact(MappedClass):
             fp=fp, artifact_id=self._id, **kw)
         return att
 
+    @LazyProperty
+    def attachments(self):
+        return self.attachment_class().query.find(dict(
+            app_config_id=self.app_config_id, artifact_id=self._id, type='attachment')).all()
+
     def delete(self):
         """Delete this Artifact.
 
@@ -462,6 +467,13 @@ class Snapshot(Artifact):
 
     def shorthand_id(self):
         return '%s#%s' % (self.original().shorthand_id(), self.version)
+    
+    @property
+    def attachments(self):
+        orig = self.original()
+        if not orig:
+            return None
+        return orig.attachments
 
     def __getattr__(self, name):
         return getattr(self.data, name)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/44963d16/Allura/allura/model/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/discuss.py b/Allura/allura/model/discuss.py
index 7f17063..a8cd7a3 100644
--- a/Allura/allura/model/discuss.py
+++ b/Allura/allura/model/discuss.py
@@ -525,10 +525,10 @@ class Post(Message, VersionedArtifact, ActivityObject):
                 subject = getattr(artifact, 'email_subject', '')
         return subject or '(no subject)'
 
-    @property
+    @LazyProperty
     def attachments(self):
         return self.attachment_class().query.find(dict(
-            post_id=self._id, type='attachment'))
+            post_id=self._id, type='attachment')).all()
 
     def add_multiple_attachments(self, file_info):
         if isinstance(file_info, list):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/44963d16/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index ec07515..4a56c1b 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -583,7 +583,7 @@ class Project(MappedClass, ActivityNode, ActivityObject):
 
     @property
     def direct_subprojects(self):
-        return self.query.find(dict(parent_id=self._id, deleted=False))
+        return self.query.find(dict(parent_id=self._id, deleted=False)).all()
 
     @property
     def accolades(self):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/44963d16/Allura/allura/templates/widgets/moderate_posts.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/moderate_posts.html b/Allura/allura/templates/widgets/moderate_posts.html
index e243b9a..25294a3 100644
--- a/Allura/allura/templates/widgets/moderate_posts.html
+++ b/Allura/allura/templates/widgets/moderate_posts.html
@@ -53,7 +53,7 @@
           <td>{{author.display_name}} ({{author.username}})</td>
           <td>{{post.thread.subject or '(no subject)'}}</td>
           <td>{{h.text.truncate(post.text,200)}}</td>
-          <td>{{post.attachments.count()}}</td>
+          <td>{{post.attachments|length}}</td>
           <td>
           {% if c.app.config.tool_name.lower() != 'discussion' %}
             <a href="{{post.thread.artifact.url()}}">[{{post.thread.artifact.shorthand_id()}}]</a>

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/44963d16/Allura/allura/tests/model/test_discussion.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_discussion.py b/Allura/allura/tests/model/test_discussion.py
index 36731bc..51a13ee 100644
--- a/Allura/allura/tests/model/test_discussion.py
+++ b/Allura/allura/tests/model/test_discussion.py
@@ -149,7 +149,7 @@ def test_post_methods():
     p.commit()
     assert p.parent is None
     assert p.subject == 'Test Thread'
-    assert p.attachments.count() == 0
+    assert_equals(p.attachments, [])
     assert 'wiki/_discuss' in p.url()
     assert p.reply_subject() == 'Re: Test Thread'
     assert p.link_text() == p.subject
@@ -222,8 +222,8 @@ def test_multiple_attachments():
     test_post = t.post('test post')
     test_post.add_multiple_attachments([test_file1, test_file2])
     ThreadLocalORMSession.flush_all()
-    assert test_post.attachments.count() == 2, test_post.attachments.count()
-    attaches = test_post.attachments.all()
+    assert_equals(len(test_post.attachments), 2)
+    attaches = test_post.attachments
     assert 'test1.txt' in [attaches[0].filename, attaches[1].filename]
     assert 'test2.txt' in [attaches[0].filename, attaches[1].filename]
 
@@ -239,8 +239,8 @@ def test_add_attachment():
     test_post = t.post('test post')
     test_post.add_attachment(test_file)
     ThreadLocalORMSession.flush_all()
-    assert test_post.attachments.count() == 1, test_post.attachments.count()
-    attach = test_post.attachments.first()
+    assert_equals(len(test_post.attachments), 1)
+    attach = test_post.attachments[0]
     assert attach.filename == 'test.txt', attach.filename
     assert attach.content_type == 'text/plain', attach.content_type
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/44963d16/Allura/allura/tests/model/test_project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_project.py b/Allura/allura/tests/model/test_project.py
index 2cd7892..c346107 100644
--- a/Allura/allura/tests/model/test_project.py
+++ b/Allura/allura/tests/model/test_project.py
@@ -121,7 +121,7 @@ def test_set_ordinal_to_admin_tool():
 
 def test_users_and_roles():
     p = M.Project.query.get(shortname='test')
-    sub = p.direct_subprojects.next()
+    sub = p.direct_subprojects[0]
     u = M.User.by_username('test-admin')
     assert p.users_with_role('Admin') == [u]
     assert p.users_with_role('Admin') == sub.users_with_role('Admin')

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/44963d16/ForgeBlog/forgeblog/model/blog.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/model/blog.py b/ForgeBlog/forgeblog/model/blog.py
index 2cd16e0..1168fe6 100644
--- a/ForgeBlog/forgeblog/model/blog.py
+++ b/ForgeBlog/forgeblog/model/blog.py
@@ -85,13 +85,6 @@ class BlogPostSnapshot(M.Snapshot):
         return g.markdown_wiki.convert(self.data.text)
 
     @property
-    def attachments(self):
-        orig = self.original()
-        if not orig:
-            return None
-        return orig.attachments
-
-    @property
     def email_address(self):
         orig = self.original()
         if not orig:

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/44963d16/ForgeImporters/forgeimporters/tests/google/functional/test_tracker.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/tests/google/functional/test_tracker.py b/ForgeImporters/forgeimporters/tests/google/functional/test_tracker.py
index ca7c8a5..528c2b6 100644
--- a/ForgeImporters/forgeimporters/tests/google/functional/test_tracker.py
+++ b/ForgeImporters/forgeimporters/tests/google/functional/test_tracker.py
@@ -182,7 +182,7 @@ class TestGCTrackerImporter(TestCase):
             )
 
     def _assert_attachments(self, actual, *expected):
-        self.assertEqual(actual.count(), len(expected))
+        self.assertEqual(len(actual), len(expected))
         atts = set((a.filename, a.content_type, a.rfile().read()) for a in actual)
         self.assertEqual(atts, set(expected))
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/44963d16/ForgeTracker/forgetracker/model/ticket.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/model/ticket.py b/ForgeTracker/forgetracker/model/ticket.py
index d0b69c2..a55efab 100644
--- a/ForgeTracker/forgetracker/model/ticket.py
+++ b/ForgeTracker/forgetracker/model/ticket.py
@@ -811,11 +811,6 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
         if who in (None, User.anonymous()): return 'nobody'
         return who.get_pref('display_name')
 
-    @property
-    def attachments(self):
-        return TicketAttachment.query.find(dict(
-            app_config_id=self.app_config_id, artifact_id=self._id, type='attachment'))
-
     def update(self, ticket_form):
         # update is not allowed to change the ticket_num
         ticket_form.pop('ticket_num', None)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/44963d16/ForgeTracker/forgetracker/templates/tracker/ticket.html
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/templates/tracker/ticket.html b/ForgeTracker/forgetracker/templates/tracker/ticket.html
index f780736..95e40a6 100644
--- a/ForgeTracker/forgetracker/templates/tracker/ticket.html
+++ b/ForgeTracker/forgetracker/templates/tracker/ticket.html
@@ -144,7 +144,7 @@
 <div id="ticket_content">
   {{g.markdown.convert(ticket.description)|safe}}
   {% if ticket.attachments %}
-    <strong class="grid-18">{{ticket.attachments.count()}} Attachments</strong>
+    <strong class="grid-18">{{ticket.attachments|length}} Attachments</strong>
     <div class="clear">
     {% for att in ticket.attachments %}
         <div class="attachment_thumb">

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/44963d16/ForgeTracker/forgetracker/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/functional/test_root.py b/ForgeTracker/forgetracker/tests/functional/test_root.py
index 823ec28..9d00bc5 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -560,7 +560,7 @@ class TestFunctionalController(TrackerTestController):
             'summary':'zzz'
         }, upload_files=[upload]).follow()
         ticket = tm.Ticket.query.find({'ticket_num':1}).first()
-        filename = ticket.attachments.first().filename
+        filename = ticket.attachments[0].filename
 
         uploaded = PIL.Image.open(file_path)
         r = self.app.get('/bugs/1/attachment/'+filename)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/44963d16/ForgeTracker/forgetracker/tests/unit/test_ticket_model.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/unit/test_ticket_model.py b/ForgeTracker/forgetracker/tests/unit/test_ticket_model.py
index 620abcf..93450d1 100644
--- a/ForgeTracker/forgetracker/tests/unit/test_ticket_model.py
+++ b/ForgeTracker/forgetracker/tests/unit/test_ticket_model.py
@@ -270,7 +270,7 @@ class TestTicketModel(TrackerTestWithModel):
             ticket = Ticket.new()
             ticket.summary = 'test ticket'
             ticket.description = 'test description'
-        assert_equal(ticket.attachments.count(), 0)
+        assert_equal(len(ticket.attachments), 0)
         f = urllib2.urlopen('file://%s' % __file__)
         TicketAttachment.save_attachment('test_ticket_model.py', ResettableStream(f),
                                             artifact_id=ticket._id)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/44963d16/ForgeWiki/forgewiki/model/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/model/wiki.py b/ForgeWiki/forgewiki/model/wiki.py
index 0321240..e4da9dc 100644
--- a/ForgeWiki/forgewiki/model/wiki.py
+++ b/ForgeWiki/forgewiki/model/wiki.py
@@ -76,10 +76,6 @@ class PageHistory(Snapshot):
         return g.markdown_wiki.convert(self.data.text)
 
     @property
-    def attachments(self):
-        return self.original().attachments
-
-    @property
     def email_address(self):
         return self.original().email_address
 
@@ -161,10 +157,6 @@ class Page(VersionedArtifact, ActivityObject):
             text=self.text)
         return result
 
-    @property
-    def attachments(self):
-        return WikiAttachment.query.find(dict(artifact_id=self._id, type='attachment'))
-
     @classmethod
     def upsert(cls, title, version=None):
         """Update page with `title` or insert new page with that name"""

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/44963d16/ForgeWiki/forgewiki/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/tests/functional/test_root.py b/ForgeWiki/forgewiki/tests/functional/test_root.py
index 3312ed7..a55176f 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_root.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_root.py
@@ -391,7 +391,7 @@ class TestRootController(TestController):
         self.app.post('/wiki/TEST/attach', upload_files=[upload])
         h.set_context('test', 'wiki', neighborhood='Projects')
         page = model.Page.query.find(dict(title='TEST')).first()
-        filename = page.attachments.first().filename
+        filename = page.attachments[0].filename
 
         uploaded = PIL.Image.open(file_path)
         r = self.app.get('/wiki/TEST/attachment/'+filename)


[6/6] git commit: [#6431] bump timermiddleware for compatibility with new ming (when debug logging)

Posted by br...@apache.org.
[#6431] bump timermiddleware for compatibility with new ming (when debug logging)


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/30f5d75f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/30f5d75f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/30f5d75f

Branch: refs/heads/master
Commit: 30f5d75fe4664c28c590ed8b559d2536a4465c34
Parents: f76bf43
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Sep 27 15:44:47 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Tue Oct 1 20:40:42 2013 +0000

----------------------------------------------------------------------
 requirements-common.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/30f5d75f/requirements-common.txt
----------------------------------------------------------------------
diff --git a/requirements-common.txt b/requirements-common.txt
index e99b5e9..1b1d2f6 100644
--- a/requirements-common.txt
+++ b/requirements-common.txt
@@ -45,7 +45,7 @@ setproctitle==1.1.7
 textile==2.1.5
 # dep of colander
 translationstring==0.4
-TimerMiddleware==0.4.3
+TimerMiddleware==0.4.4
 TurboGears2==2.1.5
 WebOb==1.0.8
 # part of the stdlib, but with a version number.  see http://guide.python-distribute.org/pip.html#listing-installed-packages