Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Some basic caching of the peer projects list.

  • Loading branch information...
commit aed21fb7ff421c1cc8352b2c8ee5c99d06cb28a7 1 parent d73d1e6
Nathan Bird authored November 04, 2010

Showing 1 changed file with 14 additions and 7 deletions. Show diff stats Hide diff stats

  1. 21  0.12/ticketmoverplugin/ticketmover.py
21  0.12/ticketmoverplugin/ticketmover.py
@@ -81,7 +81,7 @@ def get_ticket_actions(self, req, ticket):
81 81
 
82 82
         When in doubt, use a weight of 0."""
83 83
         self.env.log.debug("Adding move action.")
84  
-        if req.perm.has_permission("TICKET_ADMIN") :
  84
+        if req.perm.has_permission("TICKET_ADMIN") and len(self.projects()) > 0 :
85 85
             return [(0,"move")]
86 86
         else :
87 87
             return []
@@ -135,13 +135,20 @@ def render_ticket_action_control(self, req, ticket, action):
135 135
 
136 136
     ### internal methods
137 137
 
  138
+    _projects = None
138 139
     def projects(self):
139  
-        self.env.log.debug("Building list of peer environments")
140  
-        base_path, _project = os.path.split(self.env.path)
141  
-        return sorted([i for i in os.listdir(base_path)
142  
-                       if i != _project
143  
-                       and os.path.exists(os.path.join(base_path, i,"conf","trac.ini"))],
144  
-                      key=string.lower)
  140
+        """Build the list of peer environments based upon directories
  141
+        that contain a conf/trac.ini file"""
  142
+        if self._projects == None :
  143
+            self.env.log.debug("Building list of peer environments")
  144
+            base_path, _project = os.path.split(self.env.path)
  145
+            p = [i for i in os.listdir(base_path)
  146
+                 if i != _project
  147
+                 and os.path.exists(os.path.join(base_path, i,"conf","trac.ini"))]
  148
+            self._projects = sorted(p, key=string.lower)
  149
+        else :
  150
+            self.env.log.debug("Using cached list of peer environments.")
  151
+        return self._projects
145 152
 
146 153
     def move(self, ticket_id, author, env, delete=False):
147 154
         """

0 notes on commit aed21fb

Please sign in to comment.
Something went wrong with that request. Please try again.