home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 February / maximum-cd-2011-02.iso / DiscContents / digsby_setup85.exe / lib / gui / infobox / adapters.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-11-24  |  2.3 KB  |  67 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. from peak.util.addons import AddOn
  5. import interfaces as gui_interfaces
  6. from util.net import linkify
  7. import protocols
  8.  
  9. class IBCacheAddon(AddOn, dict):
  10.     pass
  11.  
  12.  
  13. class CachingIBP(protocols.Adapter):
  14.     protocols.advise(instancesProvide = [
  15.         gui_interfaces.ICachingInfoboxHTMLProvider])
  16.     
  17.     def __init__(self, subject):
  18.         
  19.         try:
  20.             gui_interfaces.ICacheableInfoboxHTMLProvider(subject)
  21.         except protocols.AdaptationFailure:
  22.             raise 
  23.  
  24.         return super(CachingIBP, self).__init__(subject)
  25.  
  26.     
  27.     def get_html(self, *a, **k):
  28.         c = IBCacheAddon(self.subject)
  29.         ibp = gui_interfaces.ICacheableInfoboxHTMLProvider(self.subject)
  30.         if ibp._dirty or 'cachedata' not in c:
  31.             c['cachedata'] = ibp.get_html(*a, **k)
  32.         
  33.         return c['cachedata']
  34.  
  35.  
  36.  
  37. class AccountCachingIBP(protocols.Adapter):
  38.     protocols.advise(instancesProvide = [
  39.         gui_interfaces.ICachingInfoboxHTMLProvider])
  40.     
  41.     def get_html(self, htmlfonts, make_format, *a, **k):
  42.         acct = self.subject
  43.         cachekey = '__cache__'
  44.         format_key = acct
  45.         if getattr(acct, 'header_tabs', False):
  46.             currtab = acct._current_tab
  47.             cachekey = currtab
  48.             format_key = (acct, cachekey)
  49.             dirty = acct._dirty[currtab]
  50.         elif getattr(acct, '_dirty', False):
  51.             dirty = True
  52.         else:
  53.             dirty = False
  54.         _cache = IBCacheAddon(acct)
  55.         if dirty or cachekey not in _cache:
  56.             _cache[cachekey] = linkify(make_format(htmlfonts, format_key))
  57.             if getattr(acct, 'header_tabs', False):
  58.                 acct._dirty[currtab] = False
  59.             else:
  60.                 acct._dirty = False
  61.             _cache[cachekey] = ''.join((lambda .0: for y in .0:
  62. y.strip())(_cache[cachekey].split('\n')))
  63.         
  64.         return _cache[cachekey]
  65.  
  66.  
  67.