#2415: turbokid reload templates problems
----------------------+-----------------------------------------------------
 Reporter:  xaka      |        Owner:  chrisz      
     Type:  defect    |       Status:  new         
 Priority:  normal    |    Milestone:  1.0.x bugfix
Component:  TurboKid  |      Version:  1.0.9       
 Severity:  normal    |   Resolution:              
 Keywords:            |  
----------------------+-----------------------------------------------------
Old description:

> I have found few situations where template reloading mechanism working
> wrong.
>
> {{{
> Example of situation 1.
> Templates: A, B, C
> Extends: B extends A, C extends A.
> i.e. B and C depend on A
> Reproduce: load page with template B, then load page with template C,
> then again load page with template B. NoneType exception will raised.
>
> What's wrong:
> When C see that A was changed, it delete A's module from sys.modules.
> Then loading B and it trying to get A's module info from sys.modules,
> but it doesn't exist and KeyError exception occurred.
> As result load_template method goes down and we got exception.
> }}}
>
> {{{
> Example of situation 2.
> Templates: A, B, C
> Extends: C extends B, B extends A.
> i.e. A -> B -> C
> Reproduce: load page with template C, then touch template A, then load
> page with template C again. Exception will raised.
>
> What's wrong:
> When C module loading we caching max mtime for each template depend on it
> bases.
> Lets assume that A has max mtime. mtime<A> = t1, mtime<B> = mtime<A>,
> mtime<C> = mtime<A>.
> Next we loading template B. In this process we redefine mtimes of some
> bases
> templates which stored max mtime. Now mtime<B> != mtime<A>.
> load_template method goes down again.
> }}}
>
> Too many words, yea :) and bad English, sorry for that.
> I've attach patch which fix all this bugs.

New description:

 I have found a few situations where template reloading mechanism is
 working wrong and produces an error.

 Example of situation 1:

  * Templates: A, B, C
  * Extends: B extends A, C extends A, i.e. B and C depend on A

 To reproduce the error:

  * load page with template B
  * then load page with template C
  * then again load page with template B --> a `NoneType` exception will be
 raised.

 What's wrong:

  * When C sees that A was changed, it delete A's module from
 `sys.modules`.
  * Then B loads and it tries to get A's module info from `sys.modules`,
 but it doesn't exist anymore and a `KeyError` exception occurrs.
  * As a result the `load_template` method fails and we get an exception.

 Example of situation 2:

  * Templates: A, B, C
  * Extends: C extends B, B extends A, i.e. A -> B -> C

 To reproduce the error:

  * load page with template C
  * then touch template A
  * then load page with template C again. An exception will raised.

 What's wrong:

  * When loading module C the caching max mtime for each template depends
 on it bases.
  * Let's assume that A has max mtime. `mtime<A> = t1`, `mtime<B> =
 mtime<A>`, `mtime<C> = mtime<A>`.
  * Next we load template B. In this process we redefine mtimes of some
 base templates which stored max mtime. Now `mtime<B> != mtime<A>` -->
 `load_template` method fails again.

 I've attach patch which fix all this bugs.

-- 
Ticket URL: <http://trac.turbogears.org/ticket/2415#comment:1>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development

-- 
You received this message because you are subscribed to the Google
Groups "TurboGears Tickets" group.
This group is read-only. No posting by normal members allowed.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/turbogears-tickets?hl=en?hl=en

Reply via email to