#5367 NORM Update.: journal should cache the icons extracted from bundles

Zarro Boogs per Child bugtracker at laptop.org
Thu Dec 6 14:33:02 EST 2007


#5367: journal should cache the icons extracted from bundles
-------------------------------+--------------------------------------------
  Reporter:  tomeu             |       Owner:  tomeu   
      Type:  defect            |      Status:  new     
  Priority:  normal            |   Milestone:  Update.1
 Component:  journal-activity  |     Version:          
Resolution:                    |    Keywords:  review? 
  Verified:  0                 |  
-------------------------------+--------------------------------------------
Changes (by tomeu):

  * keywords:  => review?


Comment:

 {{{
 diff --git a/misc.py b/misc.py
 index 442b24a..b1b8144 100644
 --- a/misc.py
 +++ b/misc.py
 @@ -29,6 +29,7 @@ from sugar.bundle.activitybundle import ActivityBundle
  from sugar.bundle.contentbundle import ContentBundle
  from sugar.bundle.bundle import MalformedBundleException, \
       ZipExtractException, RegistrationException
 +from sugar.util import LRU

  from journalentrybundle import JournalEntryBundle

 @@ -43,8 +44,13 @@ def _get_icon_file_name(icon_name):
      del info
      return fname

 +_icon_cache = LRU(50)
 +
  def get_icon_name(jobject):

 +    if jobject.object_id in _icon_cache:
 +        return _icon_cache[jobject.object_id]
 +
      file_name = None

      if jobject.is_activity_bundle() and jobject.file_path:
 @@ -71,6 +77,8 @@ def get_icon_name(jobject):
      if not file_name:
          return _get_icon_file_name('application-octet-stream')

 +    _icon_cache[jobject.object_id] = file_name
 +
      return file_name

  # TRANS: Relative dates (eg. 1 month and 5 days).
 }}}

-- 
Ticket URL: <http://dev.laptop.org/ticket/5367#comment:2>
One Laptop Per Child <http://dev.laptop.org>
OLPC bug tracking system



More information about the Bugs mailing list