Re: "Unsupressing" errors when called from templates

2009-10-22 Thread Peter Bengtsson

2009/10/22 bruno desthuilliers :
>
>
>
> On 21 oct, 16:00, Peter Bengtsson  wrote:
>> On 21 Oct, 14:29, bruno desthuilliers 
>> wrote:> On 21 oct, 15:05, Peter Bengtsson  wrote:
>>
>> >  a NotImplementedError would be more appropriate !-) 
>>
>> I don't know what  means
>
> oops, sorry - it's french for "OT".
>
>>
>> > Did you actually tried with this exact code ? If yes, this contradicts
>> > the FineManual(tm)
>>
>>
>> That's true for other exceptions only. E.g. ValueError or
>> ZeroDivisionError
>
> Yeps - I've seen your other posts and the link to the ticket since I
> posted this. Sorry if the answer looked a bit patronizing, but more
> often than not, posters fail to read the FineManual(tm) - or to find
> the relevant section.
>
It did but I would have written the same in reply if I suspected
someone hadn't skimmed the manual.


>> There is.http://code.djangoproject.com/ticket/11421
>>
>> I've written a patch that solves it already. Now working on tests for
>> it.
>
> Well done.
>
> >
>



-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
fun crosstips.org

--~--~-~--~~~---~--~~
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: "Unsupressing" errors when called from templates

2009-10-22 Thread bruno desthuilliers



On 21 oct, 16:00, Peter Bengtsson  wrote:
> On 21 Oct, 14:29, bruno desthuilliers 
> wrote:> On 21 oct, 15:05, Peter Bengtsson  wrote:
>
> >  a NotImplementedError would be more appropriate !-) 
>
> I don't know what  means

oops, sorry - it's french for "OT".

>
> > Did you actually tried with this exact code ? If yes, this contradicts
> > the FineManual(tm)
>
>
> That's true for other exceptions only. E.g. ValueError or
> ZeroDivisionError

Yeps - I've seen your other posts and the link to the ticket since I
posted this. Sorry if the answer looked a bit patronizing, but more
often than not, posters fail to read the FineManual(tm) - or to find
the relevant section.

> There is.http://code.djangoproject.com/ticket/11421
>
> I've written a patch that solves it already. Now working on tests for
> it.

Well done.

--~--~-~--~~~---~--~~
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: "Unsupressing" errors when called from templates

2009-10-21 Thread Peter Bengtsson



On 21 Oct, 14:29, bruno desthuilliers 
wrote:
> On 21 oct, 15:05, Peter Bengtsson  wrote:
>
> > Suppose I've got this code:
>
> > # template.html
> > Info: {{ article_instance.count_words }} words
>
> > # models.py
> > class Article(models.Model):
> >    text = models.TextField()
> >    def count_words(self):
> >         raise AttributeError('debugging')
>
>  a NotImplementedError would be more appropriate !-) 
>
I don't know what  means but it's just an example. I could have
written:
class Article(models.Model):
...
def count_words(self):
 return some_complex_calculation(article=self)

> > Then, when I render that page I get:
> > Info:  words
>
> Did you actually tried with this exact code ? If yes, this contradicts
> the FineManual(tm):
> """
> If, during the method lookup, a method raises an exception, the
> exception will be propagated, unless the exception has an attribute
> silent_variable_failure whose value is True. If the exception does
> have a silent_variable_failure attribute, the variable will render as
> an empty string.
> (...)
> Note that django.core.exceptions.ObjectDoesNotExist, which is the base
> class for all Django database API DoesNotExist exceptions, has
> silent_variable_failure = True. So if you're using Django templates
> with Django model objects, any DoesNotExist exception will fail
> silently.
> """http://docs.djangoproject.com/en/dev/ref/templates/api/#rendering-a-c...
>
That's true for other exceptions only. E.g. ValueError or
ZeroDivisionError
I can't set silent_variable_failure=True on TemplateSyntaxError. This
is only applicable when you write your own exception sub classes.

> > When I want is a raised proper error so that I can spot the possible
> > bug in my system. How do I do that?
>
> Not tested, but this might be the answer:
>
> http://docs.djangoproject.com/en/dev/ref/settings/#debug-propagate-ex...
>
I don't know what that does. Perhaps it's related to views only, not
template rendering.
Setting it to True does NOT propagate AttributeErrors in templates
rendering.

> > If what you look up in the template doesn't exist I can accept that
> > Django, currently, prefers to just suppress it
>
> Actually, there's no "suppression", 
> cfhttp://docs.djangoproject.com/en/dev/ref/templates/api/#how-invalid-v...
>
There is.
http://code.djangoproject.com/ticket/11421

I've written a patch that solves it already. Now working on tests for
it.

> HTH
--~--~-~--~~~---~--~~
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: "Unsupressing" errors when called from templates

2009-10-21 Thread bruno desthuilliers

On 21 oct, 15:05, Peter Bengtsson  wrote:
> Suppose I've got this code:
>
> # template.html
> Info: {{ article_instance.count_words }} words
>
> # models.py
> class Article(models.Model):
>    text = models.TextField()
>    def count_words(self):
>         raise AttributeError('debugging')

 a NotImplementedError would be more appropriate !-) 

> Then, when I render that page I get:
> Info:  words

Did you actually tried with this exact code ? If yes, this contradicts
the FineManual(tm):
"""
If, during the method lookup, a method raises an exception, the
exception will be propagated, unless the exception has an attribute
silent_variable_failure whose value is True. If the exception does
have a silent_variable_failure attribute, the variable will render as
an empty string.
(...)
Note that django.core.exceptions.ObjectDoesNotExist, which is the base
class for all Django database API DoesNotExist exceptions, has
silent_variable_failure = True. So if you're using Django templates
with Django model objects, any DoesNotExist exception will fail
silently.
"""
http://docs.djangoproject.com/en/dev/ref/templates/api/#rendering-a-context


> When I want is a raised proper error so that I can spot the possible
> bug in my system. How do I do that?

Not tested, but this might be the answer:

http://docs.djangoproject.com/en/dev/ref/settings/#debug-propagate-exceptions


> If what you look up in the template doesn't exist I can accept that
> Django, currently, prefers to just suppress it

Actually, there's no "suppression", cf
http://docs.djangoproject.com/en/dev/ref/templates/api/#how-invalid-variables-are-handled

HTH
--~--~-~--~~~---~--~~
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: "Unsupressing" errors when called from templates

2009-10-21 Thread Peter Bengtsson

Found the ticket for it:
http://code.djangoproject.com/ticket/11421

On 21 Oct, 14:17, Peter Bengtsson  wrote:
> UPDATE!
> If I raise some other error inside the python code (e.g. ValueError)
> it's not suppressed.
> Seems a design error in Django. Will carry on this discussion
> somewhere else.
>
> On 21 Oct, 14:05, Peter Bengtsson  wrote:
>
> > Suppose I've got this code:
>
> > # template.html
> > Info: {{ article_instance.count_words }} words
>
> > # models.py
> > class Article(models.Model):
> >    text = models.TextField()
> >    def count_words(self):
> >         raise AttributeError('debugging')
>
> > Then, when I render that page I get:
> > Info:  words
>
> > When I want is a raised proper error so that I can spot the possible
> > bug in my system. How do I do that?
>
> > If what you look up in the template doesn't exist I can accept that
> > Django, currently, prefers to just suppress it but I'm here talking
> > about things that are found but yields an exception upon executing.
--~--~-~--~~~---~--~~
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: "Unsupressing" errors when called from templates

2009-10-21 Thread Peter Bengtsson

UPDATE!
If I raise some other error inside the python code (e.g. ValueError)
it's not suppressed.
Seems a design error in Django. Will carry on this discussion
somewhere else.

On 21 Oct, 14:05, Peter Bengtsson  wrote:
> Suppose I've got this code:
>
> # template.html
> Info: {{ article_instance.count_words }} words
>
> # models.py
> class Article(models.Model):
>    text = models.TextField()
>    def count_words(self):
>         raise AttributeError('debugging')
>
> Then, when I render that page I get:
> Info:  words
>
> When I want is a raised proper error so that I can spot the possible
> bug in my system. How do I do that?
>
> If what you look up in the template doesn't exist I can accept that
> Django, currently, prefers to just suppress it but I'm here talking
> about things that are found but yields an exception upon executing.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



"Unsupressing" errors when called from templates

2009-10-21 Thread Peter Bengtsson

Suppose I've got this code:

# template.html
Info: {{ article_instance.count_words }} words

# models.py
class Article(models.Model):
   text = models.TextField()
   def count_words(self):
raise AttributeError('debugging')


Then, when I render that page I get:
Info:  words

When I want is a raised proper error so that I can spot the possible
bug in my system. How do I do that?

If what you look up in the template doesn't exist I can accept that
Django, currently, prefers to just suppress it but I'm here talking
about things that are found but yields an exception upon executing.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---