Permalink
Browse files

Some basic caching of the peer projects list.

  • Loading branch information...
1 parent d73d1e6 commit aed21fb7ff421c1cc8352b2c8ee5c99d06cb28a7 @UnwashedMeme committed Nov 4, 2010
Showing with 14 additions and 7 deletions.
  1. +14 −7 0.12/ticketmoverplugin/ticketmover.py
@@ -81,7 +81,7 @@ def get_ticket_actions(self, req, ticket):
When in doubt, use a weight of 0."""
self.env.log.debug("Adding move action.")
- if req.perm.has_permission("TICKET_ADMIN") :
+ if req.perm.has_permission("TICKET_ADMIN") and len(self.projects()) > 0 :
return [(0,"move")]
else :
return []
@@ -135,13 +135,20 @@ def render_ticket_action_control(self, req, ticket, action):
### internal methods
+ _projects = None
def projects(self):
- self.env.log.debug("Building list of peer environments")
- base_path, _project = os.path.split(self.env.path)
- return sorted([i for i in os.listdir(base_path)
- if i != _project
- and os.path.exists(os.path.join(base_path, i,"conf","trac.ini"))],
- key=string.lower)
+ """Build the list of peer environments based upon directories
+ that contain a conf/trac.ini file"""
+ if self._projects == None :
+ self.env.log.debug("Building list of peer environments")
+ base_path, _project = os.path.split(self.env.path)
+ p = [i for i in os.listdir(base_path)
+ if i != _project
+ and os.path.exists(os.path.join(base_path, i,"conf","trac.ini"))]
+ self._projects = sorted(p, key=string.lower)
+ else :
+ self.env.log.debug("Using cached list of peer environments.")
+ return self._projects
def move(self, ticket_id, author, env, delete=False):
"""

0 comments on commit aed21fb

Please sign in to comment.