Re: better error handling in templatetags?

2009-11-27 Thread KONTRA, Gergely
Thanks. With a one-line patch now I can debug templatetags :)))

Oh dear, target milestone is 1.2 I don't know why is it so slow.

Gergo
+-[ Gergely Kontra  ]--+
|   |
| Mobile:(+36 20)356 9656   |
|   |
+- "Olyan lángész vagyok, hogy poroltóval kellene járnom!" -+



On Fri, Nov 27, 2009 at 17:22, Karen Tracey  wrote:
> On Fri, Nov 27, 2009 at 5:58 AM, KONTRA, Gergely 
> wrote:
>>
>> Seems like you built your own project, and not using my zip.
>
> Yes, because just cut and pasting the template tag into my existing working
> test project seemed easier than downloading a zip file.  But even after
> retrieving the zip file and working from that (I had to remove the
> references to admin in the urls.py file since admin isn't in the
> INSTALLED_APPS setting) I still see the original traceback reflected in the
> message, so the difference between what you and I see is not due to
> differences in the projects.
>
>>
>>
>>
>> However, the result IS different.
>>
>> In my traceback I do not have any snippet referencing customtag.py.
>>
>> See my trace: http://dpaste.com/hold/125819/
>
> Hmm.  Your traceback shows you are using Python 2.6.  If I switch to that,
> then I see the behavior you are describing.  For some reason under Python
> 2.6 the exception value is being truncated at the end of the first line, so
> the original traceback is getting lost.
>
> There is a ticket open on the whole exception wrapping behavior of handing
> exceptions that occur during template rendering:
>
> http://code.djangoproject.com/ticket/11461
>
> I have not looked in detail at how things behave with the proposed patches,
> partly because since I've been seeing the original exception the wrapping
> behavior did not strike me as quite that bad.  Perhaps you can try out the
> patches, see if they improve things for your environment, and give some
> feedback.
>
> 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-us...@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.
>

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: better error handling in templatetags?

2009-11-27 Thread Karen Tracey
On Fri, Nov 27, 2009 at 5:58 AM, KONTRA, Gergely wrote:

> Seems like you built your own project, and not using my zip.
>

Yes, because just cut and pasting the template tag into my existing working
test project seemed easier than downloading a zip file.  But even after
retrieving the zip file and working from that (I had to remove the
references to admin in the urls.py file since admin isn't in the
INSTALLED_APPS setting) I still see the original traceback reflected in the
message, so the difference between what you and I see is not due to
differences in the projects.


>

However, the result IS different.
>
> In my traceback I do not have any snippet referencing customtag.py.
>
> See my trace: http://dpaste.com/hold/125819/
>

Hmm.  Your traceback shows you are using Python 2.6.  If I switch to that,
then I see the behavior you are describing.  For some reason under Python
2.6 the exception value is being truncated at the end of the first line, so
the original traceback is getting lost.

There is a ticket open on the whole exception wrapping behavior of handing
exceptions that occur during template rendering:

http://code.djangoproject.com/ticket/11461

I have not looked in detail at how things behave with the proposed patches,
partly because since I've been seeing the original exception the wrapping
behavior did not strike me as quite that bad.  Perhaps you can try out the
patches, see if they improve things for your environment, and give some
feedback.

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-us...@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: better error handling in templatetags?

2009-11-27 Thread Tim Valenta
spite* us all.

Sorry :)

On Nov 27, 8:27 am, Tim Valenta  wrote:
> Django is forced to catch your errors, and then bubble them back up to
> you.  If you notice, none of the traceback lines are even in your
> code-- it's all in Python libs or an Django code.  The issue is that
> you're not seeing raw exceptions, but instead you're seeing reproduced
> exceptions.
>
> I agree that template tags are had to debug, especially when it's a
> big complex tag that goes wrong all of the sudden.  However, don't
> forget that it's just a Python object or method, just why not fire up
> the shell and import it, testing it out?  Step through it with input
> that you *know* you're getting, and use the Django modules to create
> dummy contexts if needed (although you could probably get away with
> just Python dict objects, since the template rendering engine won't
> actually be involved).
>
> Fixing the reporting would be amazingly welcome by many of us, but
> it's not like it's a simple matter of printing a single debug variable
> that accidentally got omitted.  I don't know enough about how Django
> bubbles exceptions, so I can't say much more on the subject, but it's
> clear to me that it's not something that they're doing on purpose to
> spit us all.
>
> Tim
>
> On Nov 27, 3:58 am, "KONTRA, Gergely"  wrote:
>
>
>
> > Seems like you built your own project, and not using my zip.
>
> > However, the result IS different.
>
> > In my traceback I do not have any snippet referencing customtag.py.
>
> > See my trace:http://dpaste.com/hold/125819/
>
> > thanks
> > Gergo
> > +-[ Gergely Kontra  ]--+
> > |   |
> > | Mobile:(+36 20)356 9656   |
> > |   |
> > +- "Olyan lángész vagyok, hogy poroltóval kellene járnom!" -+
>
> > On Fri, Nov 27, 2009 at 04:38, Karen Tracey  wrote:
> > > On Thu, Nov 26, 2009 at 6:02 PM, KONTRA, Gergely 
> > > wrote:
>
> > >> My problem is the error handling of django in templatetags, not the
> > >> specific dummy error, which I programmed:
>
> > >> @register.simple_tag
> > >> def current_time():
> > >>        1/0
> > >>        return unicode(datetime.datetime.now())
>
> > >> What annoys me, that you cannot find the line number of the error,
> > >> just a message, that somewhere there is an error rendering the
> > >> current_time tag.
>
> > > With DEBUG=True, TEMPLATE_DEBUG=DEBUG, I get a TemplateSyntaxError debug
> > > page with exception value:
>
> > > Caught an exception while rendering: integer division or modulo by zero
>
> > > Original Traceback (most recent call last):
> > >   File "d:\u\kmt\django\trunk\django\template\debug.py", line 71, in
> > > render_node
> > >     result = node.render(context)
> > >   File "d:\u\kmt\django\trunk\django\template\__init__.py", line 909, in
> > > render
> > >     return func(*resolved_vars)
> > >   File "D:\u\kmt\software\web\playground\ttt\templatetags\tstuff.py", line
> > > 6, in current_time
> > >     1/0
> > > ZeroDivisionError: integer division or modulo by zero
>
> > > So I am seeing the line number of the error reported.  It's (somewhat
> > > annoyingly) not actually in the traceback portion of the page, but it is 
> > > on
> > > the page.  Are you seeing something different?
>
> > > 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-us...@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.

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: better error handling in templatetags?

2009-11-27 Thread Tim Valenta
Django is forced to catch your errors, and then bubble them back up to
you.  If you notice, none of the traceback lines are even in your
code-- it's all in Python libs or an Django code.  The issue is that
you're not seeing raw exceptions, but instead you're seeing reproduced
exceptions.

I agree that template tags are had to debug, especially when it's a
big complex tag that goes wrong all of the sudden.  However, don't
forget that it's just a Python object or method, just why not fire up
the shell and import it, testing it out?  Step through it with input
that you *know* you're getting, and use the Django modules to create
dummy contexts if needed (although you could probably get away with
just Python dict objects, since the template rendering engine won't
actually be involved).

Fixing the reporting would be amazingly welcome by many of us, but
it's not like it's a simple matter of printing a single debug variable
that accidentally got omitted.  I don't know enough about how Django
bubbles exceptions, so I can't say much more on the subject, but it's
clear to me that it's not something that they're doing on purpose to
spit us all.

Tim

On Nov 27, 3:58 am, "KONTRA, Gergely"  wrote:
> Seems like you built your own project, and not using my zip.
>
> However, the result IS different.
>
> In my traceback I do not have any snippet referencing customtag.py.
>
> See my trace:http://dpaste.com/hold/125819/
>
> thanks
> Gergo
> +-[ Gergely Kontra  ]--+
> |   |
> | Mobile:(+36 20)356 9656   |
> |   |
> +- "Olyan lángész vagyok, hogy poroltóval kellene járnom!" -+
>
>
>
> On Fri, Nov 27, 2009 at 04:38, Karen Tracey  wrote:
> > On Thu, Nov 26, 2009 at 6:02 PM, KONTRA, Gergely 
> > wrote:
>
> >> My problem is the error handling of django in templatetags, not the
> >> specific dummy error, which I programmed:
>
> >> @register.simple_tag
> >> def current_time():
> >>        1/0
> >>        return unicode(datetime.datetime.now())
>
> >> What annoys me, that you cannot find the line number of the error,
> >> just a message, that somewhere there is an error rendering the
> >> current_time tag.
>
> > With DEBUG=True, TEMPLATE_DEBUG=DEBUG, I get a TemplateSyntaxError debug
> > page with exception value:
>
> > Caught an exception while rendering: integer division or modulo by zero
>
> > Original Traceback (most recent call last):
> >   File "d:\u\kmt\django\trunk\django\template\debug.py", line 71, in
> > render_node
> >     result = node.render(context)
> >   File "d:\u\kmt\django\trunk\django\template\__init__.py", line 909, in
> > render
> >     return func(*resolved_vars)
> >   File "D:\u\kmt\software\web\playground\ttt\templatetags\tstuff.py", line
> > 6, in current_time
> >     1/0
> > ZeroDivisionError: integer division or modulo by zero
>
> > So I am seeing the line number of the error reported.  It's (somewhat
> > annoyingly) not actually in the traceback portion of the page, but it is on
> > the page.  Are you seeing something different?
>
> > 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-us...@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.

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: better error handling in templatetags?

2009-11-27 Thread KONTRA, Gergely
Seems like you built your own project, and not using my zip.

However, the result IS different.

In my traceback I do not have any snippet referencing customtag.py.

See my trace: http://dpaste.com/hold/125819/

thanks
Gergo
+-[ Gergely Kontra  ]--+
|   |
| Mobile:(+36 20)356 9656   |
|   |
+- "Olyan lángész vagyok, hogy poroltóval kellene járnom!" -+



On Fri, Nov 27, 2009 at 04:38, Karen Tracey  wrote:
> On Thu, Nov 26, 2009 at 6:02 PM, KONTRA, Gergely 
> wrote:
>>
>> My problem is the error handling of django in templatetags, not the
>> specific dummy error, which I programmed:
>>
>> @register.simple_tag
>> def current_time():
>>        1/0
>>        return unicode(datetime.datetime.now())
>>
>> What annoys me, that you cannot find the line number of the error,
>> just a message, that somewhere there is an error rendering the
>> current_time tag.
>>
>
> With DEBUG=True, TEMPLATE_DEBUG=DEBUG, I get a TemplateSyntaxError debug
> page with exception value:
>
> Caught an exception while rendering: integer division or modulo by zero
>
> Original Traceback (most recent call last):
>   File "d:\u\kmt\django\trunk\django\template\debug.py", line 71, in
> render_node
>     result = node.render(context)
>   File "d:\u\kmt\django\trunk\django\template\__init__.py", line 909, in
> render
>     return func(*resolved_vars)
>   File "D:\u\kmt\software\web\playground\ttt\templatetags\tstuff.py", line
> 6, in current_time
>     1/0
> ZeroDivisionError: integer division or modulo by zero
>
> So I am seeing the line number of the error reported.  It's (somewhat
> annoyingly) not actually in the traceback portion of the page, but it is on
> the page.  Are you seeing something different?
>
> 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-us...@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.
>

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: better error handling in templatetags?

2009-11-26 Thread Karen Tracey
On Thu, Nov 26, 2009 at 6:02 PM, KONTRA, Gergely wrote:

> My problem is the error handling of django in templatetags, not the
> specific dummy error, which I programmed:
>
> @register.simple_tag
> def current_time():
>1/0
>return unicode(datetime.datetime.now())
>
> What annoys me, that you cannot find the line number of the error,
> just a message, that somewhere there is an error rendering the
> current_time tag.
>
>
With DEBUG=True, TEMPLATE_DEBUG=DEBUG, I get a TemplateSyntaxError debug
page with exception value:

Caught an exception while rendering: integer division or modulo by zero

Original Traceback (most recent call last):
  File "d:\u\kmt\django\trunk\django\template\debug.py", line 71, in
render_node
result = node.render(context)
  File "d:\u\kmt\django\trunk\django\template\__init__.py", line 909, in
render
return func(*resolved_vars)
  File "D:\u\kmt\software\web\playground\ttt\templatetags\tstuff.py", line
6, in current_time
1/0
ZeroDivisionError: integer division or modulo by zero

So I am seeing the line number of the error reported.  It's (somewhat
annoyingly) not actually in the traceback portion of the page, but it is on
the page.  Are you seeing something different?

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-us...@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: better error handling in templatetags?

2009-11-26 Thread KONTRA, Gergely
My problem is the error handling of django in templatetags, not the
specific dummy error, which I programmed:

@register.simple_tag
def current_time():
1/0
return unicode(datetime.datetime.now())

What annoys me, that you cannot find the line number of the error,
just a message, that somewhere there is an error rendering the
current_time tag.

+-[ Gergely Kontra  ]--+
|   |
| Mobile:(+36 20)356 9656   |
|   |
+- "Olyan lángész vagyok, hogy poroltóval kellene járnom!" -+



On Thu, Nov 26, 2009 at 17:35, Karen Tracey  wrote:
> On Thu, Nov 26, 2009 at 9:09 AM, pihentagy  wrote:
>>
>> Isn't it a known thing, that template tags are hard to debug? Did I
>> miss something?
>
> I don't know, but your original message makes it a little too hard to try to
> help probably.  You say the actual location of the error is missing, but in
> order to see what you are seeing people have to download a zip file from
> somewhere and go to some trouble to unzip and install and figure out what to
> run to recreate the problem, etc.  Why not just post the traceback you are
> getting, along with whatever snippets of the associated code that are
> relevant? You might get better feedback from that.
>
> Karen
>
>>
>>
>>
>> On Nov 11, 11:13 am, pihentagy  wrote:
>> > Hi all!
>> >
>> > I am not satisfied with the error handling inside custom template
>> > tags.
>> > To demonstrate it, I cooked a mini useless app, which can be
>> > downloaded here:
>> >
>> > What I miss from the error screen is the actual location of the error.
>> >
>> > http://cid-a93120a1b42a9e7f.skydrive.live.com/self.aspx/.Public/djang...
>> >
>> > Or did I do something wrong, that I miss the error message?
>>
>> --
>>
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-us...@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.
>>
>>
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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.
>

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: better error handling in templatetags?

2009-11-26 Thread Karen Tracey
On Thu, Nov 26, 2009 at 9:09 AM, pihentagy  wrote:

> Isn't it a known thing, that template tags are hard to debug? Did I
> miss something?
>

I don't know, but your original message makes it a little too hard to try to
help probably.  You say the actual location of the error is missing, but in
order to see what you are seeing people have to download a zip file from
somewhere and go to some trouble to unzip and install and figure out what to
run to recreate the problem, etc.  Why not just post the traceback you are
getting, along with whatever snippets of the associated code that are
relevant? You might get better feedback from that.

Karen


>
>
On Nov 11, 11:13 am, pihentagy  wrote:
> > Hi all!
> >
> > I am not satisfied with the error handling inside custom template
> > tags.
> > To demonstrate it, I cooked a mini useless app, which can be
> > downloaded here:
> >
> > What I miss from the error screen is the actual location of the error.
> >
> > http://cid-a93120a1b42a9e7f.skydrive.live.com/self.aspx/.Public/djang...
> >
> > Or did I do something wrong, that I miss the error message?
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>
>

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: better error handling in templatetags?

2009-11-26 Thread pihentagy
Isn't it a known thing, that template tags are hard to debug? Did I
miss something?

On Nov 11, 11:13 am, pihentagy  wrote:
> Hi all!
>
> I am not satisfied with the error handling inside custom template
> tags.
> To demonstrate it, I cooked a mini useless app, which can be
> downloaded here:
>
> What I miss from the error screen is the actual location of the error.
>
> http://cid-a93120a1b42a9e7f.skydrive.live.com/self.aspx/.Public/djang...
>
> Or did I do something wrong, that I miss the error message?

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.




better error handling in templatetags?

2009-11-11 Thread pihentagy

Hi all!

I am not satisfied with the error handling inside custom template
tags.
To demonstrate it, I cooked a mini useless app, which can be
downloaded here:

What I miss from the error screen is the actual location of the error.

http://cid-a93120a1b42a9e7f.skydrive.live.com/self.aspx/.Public/djangotest.zip

Or did I do something wrong, that I miss the error message?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---