Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #2415: 02-reload-templates-fix.patch

File 02-reload-templates-fix.patch, 2.2 KB (added by xaka, 2 years ago)
  • turbokid/kidsupport.py

    old new  
    121121                        ttime = mtime 
    122122                    # Check the status of all base moduls. 
    123123                    for module in _get_extended_modules(tclass): 
    124                         mtime = stat(sys.modules[module].__file__).st_mtime 
     124                        # In some situations module will not exist in 
     125                        # sys.modules dict and we should correctly handle 
     126                        # this situation to prevent from KeyError exception 
     127                        # raising. 
     128                        # Load mtime of base module from cache 
     129                        # in this situation 
     130                        try: 
     131                            mtime = stat(sys.modules[module].__file__).st_mtime 
     132                        except KeyError: 
     133                            mtime = ct[module] 
     134 
    125135                        if mtime > ct[module]: 
    126136                            # base template has changed 
    127137                            del sys.modules[module] 
    128138                            ct[module] = mtime 
    129139                            reload_template = True 
     140 
    130141                        if mtime > ttime: 
    131142                            # base module has changed 
    132143                            reload_template = True 
     
    152163                    ttime = stat(sys.modules[classname].__file__).st_mtime 
    153164                    for module in _get_extended_modules(tclass): 
    154165                        mtime = stat(sys.modules[module].__file__).st_mtime 
    155                         ct[module] = mtime 
     166 
     167                        # we must use setdefault instead of ct[module] = mtime 
     168                        # to prevent from modification already calculated max 
     169                        # mtimes for loaded base templates 
     170                        ct.setdefault(module, mtime) 
     171 
    156172                        if mtime > ttime: 
    157173                            ttime = mtime 
    158174                    # Store max of mtimes of template and all of its bases.