Ticket #6436: cache-get_ticket_fields-trac-0.10.diff
| File cache-get_ticket_fields-trac-0.10.diff, 1.8 kB (added by cboos, 6 months ago) |
|---|
-
trac/ticket/api.py
15 15 # Author: Jonas Borgström <jonas@edgewall.com> 16 16 17 17 import re 18 try: 19 import threading 20 except ImportError: 21 import dummy_threading as threading 18 22 19 23 from trac.config import * 20 24 from trac.core import * … … 68 72 [TracTickets#Assign-toasDrop-DownList Assign-to as Drop-Down List] 69 73 (''since 0.9'').""") 70 74 75 def __init__(self): 76 self._fields_lock = threading.RLock() 77 71 78 # Public API 72 79 73 80 def get_available_actions(self, ticket, perm_): … … 85 92 86 93 def get_ticket_fields(self): 87 94 """Returns the list of fields available for tickets.""" 95 # This is now cached - as it makes quite a number of things faster, 96 # e.g. #6436 97 if self._fields is None: 98 self._fields_lock.acquire() 99 try: 100 self._fields = self._get_ticket_fields() 101 finally: 102 self._fields_lock.release() 103 return self._fields 104 105 _fields = None 106 def _get_ticket_fields(self): 88 107 from trac.ticket import model 89 108 90 109 db = self.env.get_db_cnx() … … 155 174 return fields 156 175 157 176 def get_custom_fields(self): 177 if self._custom_fields is None: 178 self._fields_lock.acquire() 179 try: 180 self._custom_fields = self._get_custom_fields() 181 finally: 182 self._fields_lock.release() 183 return self._custom_fields 184 185 _custom_fields = None 186 def _get_custom_fields(self): 158 187 fields = [] 159 188 config = self.config['ticket-custom'] 160 189 for name in [option for option, value in config.options()
