jackrosenthal / kajiki

Python XML-based template engine with Genshi-like syntax and Jinja-style blocks
Other
47 stars 16 forks source link

reload does not work, at least with derived filenames #28

Open alexbodn opened 7 years ago

alexbodn commented 7 years ago

hello friends, i'm using kajiki templates as mixed direct and dotted filenames. the reload functionality had to be fixed, so i united it under the smaller common denominator: the resolved filename.

please review my included patch:

alex kajiki.diff.txt

amol- commented 7 years ago

Were you using Kajiki directly or through TurboGears? (Asking because turbogears provides a custom FileLoader for kajiki) Can you provide a short example that showcases how autoreload doesn't work?

amol- commented 7 years ago

Asking because the quickstarted app of TG leverages mixing: dotted, standard filenames, dotted with forced extension and seems to properly work:

On first load:

CHECKING provak.templates.index
LOADING provak.templates.index
CHECKING master.xhtml
LOADING master.xhtml
CHECKING tgext.debugbar.templates.debugbar!html
LOADING tgext.debugbar.templates.debugbar!html

On next load:

CHECKING provak.templates.index
FROM CACHE provak.templates.index
CHECKING master.xhtml
FROM CACHE master.xhtml
CHECKING tgext.debugbar.templates.debugbar!html
FROM CACHE tgext.debugbar.templates.debugbar!html

After changing index:

CHECKING provak.templates.index
---> LOADING provak.templates.index
CHECKING master.xhtml
FROM CACHE master.xhtml
CHECKING tgext.debugbar.templates.debugbar!html
FROM CACHE tgext.debugbar.templates.debugbar!html

After changing master:

CHECKING provak.templates.index
FROM CACHE provak.templates.index
CHECKING master.xhtml
---> LOADING master.xhtml
CHECKING tgext.debugbar.templates.debugbar!html
FROM CACHE tgext.debugbar.templates.debugbar!html
amol- commented 7 years ago

I think I understood what you meant. You are mixing provak.templates.index and provak/templates/index.html inside the same app and the two end up being cached with two different cache keys.

alexbodn commented 7 years ago

thanks @amol for your consideration. i'm happily using tg indeed, and that's the source of the dotted from, thanks. but i'm not calling the same template both ways. even though is may happen somehow ;) . just the '''name''' of the template could not be found in '''self.modules'''. probably one case has been used before and the other after, the '''filename''' method. anyway, reducing all the names dealing to the filename makes most sense to me, since, and as far as, it's all about real files.

alexbodn commented 7 years ago

one more source of error could be my usage of the templates search path from turbogears. then, the original filenames will be truncated.