Hello, I made all tests green finally (all commits are tested under Python 
2.7.3 and 3.2.3). The problem that took a few days to solve was that the 
default engine should be recomputed after changing TEMPLATE_LOADERS setting 
since its _template_source_loaders internal needs to be recalculated. I 
tried to solve it by adding receiver in template/base.py and then 
circular-imports problem occured. I tried to solve it (that took a few 
days). Fortunately, I asked apollo13 and he helped me and told me that I 
should put the receiver to test/signals.py so I did it.

I also updated master which is important since the hierarchy of test files 
was restructured. I kept old branch and created new called ticket_17093v3 
[new-branch]. The patch is ready to first review (however it still lack 
documentation).

After gathering all pieces of global state into one, I started to do some 
clean up. I noticed that the cache loader unnecessary procrastinates 
resolving loaders list, so I moved the resolving to __init__.

Now there is still a lot of mess in the template system. The mess is about 
passing on origin of template and some APIs. For example, 
TemplateEngine.find_template and BaseLoader.load_template return tuple 
instead of a template. The second element of the tuple is display_name 
which is necessary to compute origin of template (and the origin is 
computed in many places! [computing-origin]). The first element may be not 
a Template instance but... its source.

My plan is that TemplateEngine.find_template and BaseLoader.load_template 
will return only a Template instance (and no display_name!). The Template 
will be created in BaseLoader.load_template and that will be place for 
computing origin of template. That will be much more simpler API than the 
current one. I tried to do this, but there are some problems.

The main problem is somehow buggy (in my opinion) behaviour of 
TemplateEngine.find_template [buggy-find-template]. If a loader raises 
TemplateDoesNotExist, then we catch this exception and check next loader. 
However, this is not what should be done. Look at the case when the 
template exists, but it includes a missing template. Including missing 
template raises the exception and it shouldn't be caught by find_template. 
The problem occured in many tickets [tickets] but the patches didn't solve 
the problem -- they're only a workarounds in my opinion.

I think that find_template should distinguish why the TemplateDoesNotExist 
was raised (because the current template is missing or because the current 
template exists but it includes some missing templates). The simplest 
solution is to ensure that the TemplateDoesNotExist is created with 
template name as its argument (with the exception of 
TemplateEngine.select_template case). Then find_template should check if 
the template name in exception is equal to `name` argument. If it's not 
true then reraise the exception loudly. Otherwise make it silent.

I partially did the changes (however, I didn't pushed it into the branch), 
and it works. My question is if the changes of API are acceptable since 
they are backward incompatible. The changes includes: TemplateDoesNotExist 
(added template_name argument in constructor), TemplateEngine.find_template 
and BaseLoader.load_template (and its subclasses)(changed return values).

Now I would like to ask about GSOC. Last time I told about my idea of 
introducing rendererers. Now I think that it doesn't introduce many 
improvements -- now you can use Django REST Framework (as Tom said) for 
JSON or you can just write your own render_to_response delegating to mako 
template system. So I dropped this idea. Now I wonder what are priorities?

   - Continuing refactoring (and adding new features) of template system. 
   Better error reporting. Logging invalid variable lookups. Compiling Django 
   templates into python functions so they will render faster.
   - Refactoring another part of Django. Is there any wiki page about how 
   Django should be refactored and what principles should I base on when I 
   restructure Django?
   - Improving error reporting.
   - Revamping of validation functionality.
   - Test framework cleanup. Speeding up tests. Splitting long tests 
   migrated from doctests. Testing Django application "in a void" 
   (independently of Django project and everything else). Running all tests 
   against different databases backends in sequence?
   
Please tell me which of these are most interesting for you (and which one 
have the greates chance to be a GSoC project). Which ones are important and 
which ones negligible? The list of ideas from 2012 doesn't contain 
information which ones are priorities. I would like to know to focus on the 
most important first.

[new-branch] https://github.com/chrismedrela/django/tree/ticket_17093v3
[computing-origin] Run `git grep -n make_origin`
[buggy-find-template] 
https://github.com/chrismedrela/django/blob/ticket_17093v3/django/template/base.py#L1362
[tickets] https://code.djangoproject.com/ticket/12787
[tickets] https://code.djangoproject.com/ticket/15502
[tickets] https://code.djangoproject.com/ticket/15510

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to