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 #55 (closed defect: fixed)

Opened 12 years ago

Last modified 10 years ago

Make base templates reload automatically

Reported by: kevin Owned by: dstanek
Priority: high Milestone: 0.9a3
Component: Kid Version:
Severity: normal Keywords:
Cc:

Description

Currently, base templates defined either via view.baseTemplates or py:extends="'foo.kid'" don't reload automatically while in development. This is very inconvenient.

Attachments

template_reloading.patch Download (3.6 KB) - added by dstanek 11 years ago.
bases.patch Download (1.6 KB) - added by dstanek 11 years ago.
If you want to reload bases you need to set 'kid.reloadbases'. This may not work for everyone!
bases.2.patch Download (1.6 KB) - added by dstanek 11 years ago.
If you want to reload bases you need to set 'kid.reloadbases'. This may not work for everyone!

Change History

comment:1 Changed 12 years ago by kevin

  • Milestone set to 0.9

comment:2 Changed 12 years ago by SuperJared

Extends may be dramatically changed:  http://lesscode.org/projects/kid/ticket/76

comment:3 Changed 12 years ago by kevin

  • Priority changed from normal to high

The "right way" to do this is

1) in turbogears.view, make it check the basetemplates to see if they've changed before rendering out a template 2) in Kid, when using py:extends="'foo.kid'", do something to have Kid check if the file has changed

If that appears too onerous, making the autoreload functionality check the base templates seems like another route. This is a bit aggressive, as it actually restarts the server, but it would certainly work.

comment:4 Changed 12 years ago by ianb@…

The lazy way to do this: add the templates to the reloader when they are loaded, restart the whole process when they are changed.

comment:5 Changed 12 years ago by dstanek@…

  • Owner changed from anonymous to dstanek

comment:6 Changed 11 years ago by dstanek

I created a patch that seems to work in my small environment. The old reloading mechanism was very simple. When KidSupport.load_template was called the template file's mtime was compared to a saved mtime. If the file was newer it was reloaded.

I have enhanced this mechanism to also recursively check the __bases__ of a template. If a base template's mtime is newer that the template's mtime it is reloaded.

I will be patching Kid so that it stores the mtime for modules that it creates. This will allow the TG code to compare a base template's mtime against it's own stored mtime. And will make the process much more fool proof. It's not perfect, but it is a start.

Changed 11 years ago by dstanek

comment:7 Changed 11 years ago by kevin

  • Status changed from new to closed
  • Resolution set to fixed

committed in [404]. Thanks!

comment:8 Changed 11 years ago by dstanek

  • Status changed from closed to reopened
  • Resolution fixed deleted

The original patch for this seemed to have errors on some setups.

Changed 11 years ago by dstanek

If you want to reload bases you need to set 'kid.reloadbases'. This may not work for everyone!

Changed 11 years ago by dstanek

If you want to reload bases you need to set 'kid.reloadbases'. This may not work for everyone!

comment:9 Changed 11 years ago by kevin

I committed this patch in [535] along with a change in view.py to propogate the setting. To get this change, you'll need to reinstall (or setup.py develop) TurboKid?.

comment:10 Changed 11 years ago by kevin

I just ([787]) committed a change to get normal template reloading again. Base template reloading support looks almost entirely gone from the module. We should resurrect this sometime soon.

comment:11 Changed 11 years ago by kevin

  • Milestone changed from 0.9 to 0.9a3

Michele has checked in an attempt at this in [1040].

comment:12 Changed 11 years ago by kevin

  • Status changed from reopened to closed
  • Resolution set to fixed

I just double checked this and verified that it works with an update to TurboKid?.

Note: See TracTickets for help on using tickets.