Ticket #55 (closed defect: fixed)
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
Change History
comment:2 Changed 7 years ago by SuperJared
Extends may be dramatically changed: http://lesscode.org/projects/kid/ticket/76
comment:3 Changed 7 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 7 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:6 Changed 6 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.
comment:7 Changed 6 years ago by kevin
- Status changed from new to closed
- Resolution set to fixed
committed in [404]. Thanks!
comment:8 Changed 6 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 6 years ago by dstanek
-
attachment
bases.patch
added
If you want to reload bases you need to set 'kid.reloadbases'. This may not work for everyone!
Changed 6 years ago by dstanek
-
attachment
bases.2.patch
added
If you want to reload bases you need to set 'kid.reloadbases'. This may not work for everyone!
comment:10 Changed 6 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 6 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 6 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?.