Re: TemplateDoesNotExist error when postmortem says it exists?

2009-03-29 Thread Russell Keith-Magee

On Mon, Mar 30, 2009 at 1:42 AM, Rob Hudson  wrote:
>
> Wow, that was a tricky one to track down...
...
> I take it that gets interpreted as a single value tuple.  D'oh!  That

It does, operator precedence notwithstanding (for example, a lambda
expression returning a tuple that is being used as an argument to a
function may not interpret an unbracketed tuple, but as a second
function argument)

> What's interesting to me, is that the file path got converted
> correctly in the debug output but not in the template loader itself.

That's an edge case of string variable expansion:

print "Hello %s world" % foo

and:

print "Hello %s world" % (foo,)

give the same result. However, this flexibility isn't automatically
extended to any other usage of a single value tuple - the code needs
to explicitly allow tuples for input. The template loader doesn't.

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: TemplateDoesNotExist error when postmortem says it exists?

2009-03-29 Thread Rob Hudson

Wow, that was a tricky one to track down...

After putting debug output in django/template/loaders/filesystem.py I
saw that filepath was set to:

'/Users/rob/git/anglers/anglers/templates/('book/
search_form.html',)'

I back tracked that and found that I had a trailing comma in my view
code:

if not template:
template = 'book/search_form.html',

I take it that gets interpreted as a single value tuple.  D'oh!  That
got there from a refactor where I copy/pasted that string when it was
in an extra_context dictionary and didn't notice the comma.

What's interesting to me, is that the file path got converted
correctly in the debug output but not in the template loader itself.

-Rob
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: TemplateDoesNotExist error when postmortem says it exists?

2009-03-29 Thread Rob Hudson

On Sun, Mar 29, 2009 at 8:28 AM, Karen Tracey  wrote:
> That generally means the permissions don't allow the code to access the
> file.  You don't mention if this happens with the dev server (which would
> surprise me, since you can load the template from the shell) or only with a
> real web server. If it's only with the real web server than I expect the
> permissions need to be fixed so that the web server can read the template
> file.

Yes, it's using the dev server.  I did check the permissions just in
case and they look fine (-rw-r--r--).

What is odd is I'm also using this template from a different view and
it loads fine.  I'm trying to debug now but I'm about to run out of
time and thought I'd throw it out here if anyone else encountered
this.

Thanks,
-Rob

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: TemplateDoesNotExist error when postmortem says it exists?

2009-03-29 Thread Karen Tracey
On Sun, Mar 29, 2009 at 11:18 AM, Rob Hudson  wrote:

>
> This is a stumper...
>
> I have a very simple view that is a wrapper around the generic view
> direct_to_template.  The loader finds the template as indicated in the
> output "(File exists)", but yet I still get a TemplateDoesNotExist
> error.  Any ideas?
>

That generally means the permissions don't allow the code to access the
file.  You don't mention if this happens with the dev server (which would
surprise me, since you can load the template from the shell) or only with a
real web server. If it's only with the real web server than I expect the
permissions need to be fixed so that the web server can read the template
file.

Karen

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



TemplateDoesNotExist error when postmortem says it exists?

2009-03-29 Thread Rob Hudson

This is a stumper...

I have a very simple view that is a wrapper around the generic view
direct_to_template.  The loader finds the template as indicated in the
output "(File exists)", but yet I still get a TemplateDoesNotExist
error.  Any ideas?

I can go to the Django shell and load it just fine:
> ./manage.py shell
>>> from django.template.loader import get_template
>>> t = get_template('book/search_form.html')
>>> t

>>> t.name
'book/search_form.html'

Copy/Paste from debug output:

Template Loader Error:
Django tried loading these templates, in this order:
  Using loader
django.template.loaders.filesystem.load_template_source:
/Users/rob/git/anglers/anglers/templates/book/search_form.html
(File exists)
  Using loader
django.template.loaders.app_directories.load_template_source:
/Users/rob/django/django/django/contrib/admin/templates/book/
search_form.html (File does not exist)

Traceback:
File "/Users/rob/django/django/django/core/handlers/base.py" in
get_response
  92. response = callback(request, *callback_args,
**callback_kwargs)
File "/Users/rob/django/django/django/contrib/auth/decorators.py" in
__call__
  67. return self.view_func(request, *args, **kwargs)
File "/Users/rob/git/anglers/anglers/../anglers/book/views.py" in
search_form
  102. extra_context=extra_context,
File "/Users/rob/django/django/django/views/generic/simple.py" in
direct_to_template
  17. t = loader.get_template(template)
File "/Users/rob/django/django/django/template/loader.py" in
get_template
  81. source, origin = find_template_source(template_name)
File "/Users/rob/django/django/django/template/loader.py" in
find_template_source
  74. raise TemplateDoesNotExist, name

Exception Type: TemplateDoesNotExist at /advanced-search/
Exception Value: book/search_form.html

I'm using Django 1.1 beta 1.

Thanks,
Rob
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---