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  

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

Re: better error handling in templatetags?

2009-11-27 Thread Tim Valenta
y trace:http://dpaste.com/hold/125819/ > > > thanks > > Gergo > > +-[ Gergely Kontra  ]--+ > > |   | > > | Mobile:(+36 20)356 9656   | > > |   | > > +- "Olyan lán

Re: better error handling in templatetags?

2009-11-27 Thread Tim Valenta
  | > +- "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 o

Re: better error handling in templatetags?

2009-11-27 Thread KONTRA, Gergely
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

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(

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

Re: better error handling in templatetags?

2009-11-26 Thread Karen Tracey
iated 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

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

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

Re: Error handling. Catching DoesNotExist errors.

2009-06-21 Thread Beals
There's even a shortcut for that! http://www.djangoproject.com/documentation/models/get_or_create/ On Jun 21, 4:03 am, soniiic wrote: > if you'd like to create a book you could have also tried: > > def getBook(request, bookID): > try: >     book = Books.objects.get(id=bookID) > catch Book.DoesN

Re: Error handling. Catching DoesNotExist errors.

2009-06-21 Thread soniiic
if you'd like to create a book you could have also tried: def getBook(request, bookID): try:     book = Books.objects.get(id=bookID) catch Book.DoesNotExist: #create book here return render_to_response('book.html', {'book': book}) Not useful in this situation but I used it in one of my proje

Re: Error handling. Catching DoesNotExist errors.

2009-06-20 Thread Wayne Koorts
> Hah! Incredibly simple! I love Django! I had a few moments like that in the past few days :-) Regards, Wayne --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email

Re: Error handling. Catching DoesNotExist errors.

2009-06-20 Thread Magnus Valle
Hah! Incredibly simple! I love Django! Thank you very much, Wayne! On 21/06/2009, Wayne Koorts wrote: > >> I have a function that looks like this: >> >> def getBook(request, bookID): >>    book = Books.objects.get(id=bookID) >>    return render_to_response('book.html', {'book': book}) >> >> Doe

Re: Error handling. Catching DoesNotExist errors.

2009-06-20 Thread Wayne Koorts
> I have a function that looks like this: > > def getBook(request, bookID): >    book = Books.objects.get(id=bookID) >    return render_to_response('book.html', {'book': book}) > > DoesNotExist at /books/8 > Books matching query does not exist. > > How do I make it redirect to a 404 instead? Ther

Error handling. Catching DoesNotExist errors.

2009-06-20 Thread Magnus Valle
I have a function that looks like this: def getBook(request, bookID): book = Books.objects.get(id=bookID) return render_to_response('book.html', {'book': book}) bookID is a \d. In a url like this www.example.com/books/8 bookID will be 8. And the the page response will be the 8th book in

Re: Integrity error handling

2009-05-27 Thread orokusaki
In your form sub-class class you'll need to override the clean method to check for duplicate entries and raise a validation error if they exists: from somewhere import models from somewhere import forms class myForm(forms.ModelForm): some_unique_field = forms.CharField() class M

Re: Integrity error handling

2009-05-21 Thread Bobby Roberts
any ideas? --~--~-~--~~~---~--~~ 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.

Integrity error handling

2009-05-20 Thread Bobby Roberts
hi group I have a situation here. I need to make sure that a field is unique in the database. In my model i have the following: url= models.CharField (max_length=254, blank=False, db_index=True,unique=True) When i go to save, it throws the IntegrityError just like it should. How can i tra

error handling

2009-04-07 Thread skunkwerk
Hi, is there any way to log errors (regardless of whether Debug is true or false) instead of just displaying a debug trace/emailing the admins? is there some setting somewhere, or would I have to write some additional code like this: http://www.djangosnippets.org/snippets/639/ to get it workin

Re: None model error handling in view

2008-11-09 Thread Daniel Roseman
On Nov 9, 12:28 pm, VP <[EMAIL PROTECTED]> wrote: > Unfortunatelly I don't know how to get that traceback. > If the exception happens from a model e.g. > > try: >     b = Blog.objects.get(id = 1) > except Blog.DoesNotExist: >     b = Blog(name = 'MyBlog') >     b.save() >     b = b.id > > It works

Re: None model error handling in view

2008-11-09 Thread VP
Unfortunatelly I don't know how to get that traceback. If the exception happens from a model e.g. try: b = Blog.objects.get(id = 1) except Blog.DoesNotExist: b = Blog(name = 'MyBlog') b.save() b = b.id It works very well. But following not: try: for row in csv.reader(request

Re: None model error handling in view

2008-11-09 Thread Daniel Roseman
On Nov 9, 3:00 am, VP <[EMAIL PROTECTED]> wrote: > Hi all, > > How to handle errors from different modules, for example CSV or > DATETIME in view? > I am trying to parse CSV content in my view after an uplod a file by > user. > > def my_view(request): >     ... >     try: >         for row in csv.

None model error handling in view

2008-11-08 Thread VP
Hi all, How to handle errors from different modules, for example CSV or DATETIME in view? I am trying to parse CSV content in my view after an uplod a file by user. def my_view(request): ... try: for row in csv.reader(request.FILES['file']): for i in range(0, len(row)

Re: Form.clean() and custom error handling

2008-07-22 Thread Malcolm Tredinnick
On Tue, 2008-07-22 at 15:20 -0700, John-Scott wrote: > All, > > I had previously been using a bit of a hack (thought I found examples > of this on the mailing list, but can't find any evidence now) so that > I could actually associated field specific errors with the actual > field instead of hav

Form.clean() and custom error handling

2008-07-22 Thread John-Scott
All, I had previously been using a bit of a hack (thought I found examples of this on the mailing list, but can't find any evidence now) so that I could actually associated field specific errors with the actual field instead of having everything stuffed into __all__ / non_field_errors. The hack

Re: Multiple validation error handling in clean()

2008-02-14 Thread robstar
That worked ! I like that solution much better too! Thanks for your help. Rob On Feb 14, 2:14 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Thu, 2008-02-14 at 10:54 -0800, robstar wrote: > > Thanks Malcolm, I'll try it out. > > > Some of this feels kind of hack'ey what's the co

Re: Multiple validation error handling in clean()

2008-02-14 Thread Malcolm Tredinnick
On Thu, 2008-02-14 at 10:54 -0800, robstar wrote: > Thanks Malcolm, I'll try it out. > > Some of this feels kind of hack'ey what's the correct, clean way > to do this kind of processing with newforms?? Putting an error against two fields simultaneously isn't a very normal practice. You're

Re: Multiple validation error handling in clean()

2008-02-14 Thread robstar
Thanks Malcolm, I'll try it out. Some of this feels kind of hack'ey what's the correct, clean way to do this kind of processing with newforms?? Rob On Feb 14, 1:49 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Thu, 2008-02-14 at 10:20 -0800, robstar wrote: > > [...] > > > > > I'

Re: Multiple validation error handling in clean()

2008-02-14 Thread Malcolm Tredinnick
On Thu, 2008-02-14 at 10:20 -0800, robstar wrote: [...] > I'm not really sure how to process this list in the template.. or how > it gets stored for the correct field. Suppose I have this code in > clean(): > > rc = 0 > if 'captcha' in self.cleaned_data: > if not self

Re: Multiple validation error handling in clean()

2008-02-14 Thread robstar
Ok, I found some useful info posted by Malcolm: "Form.errors is an ErrorDict (from newforms.util), which maps field names to ErrorList instances. It is important to use ErrorList classes as the values in that dictionary, because they know how to display themselves properly. I'm not really alongs

Re: Multiple validation error handling in clean()

2008-02-14 Thread robstar
Oops, I found some info in search this might answer my question .. thanks anyway ! :) rob On Feb 14, 1:09 pm, robstar <[EMAIL PROTECTED]> wrote: > Hi guys, > > I'm working my way through the newforms and it's pretty cool.. but I'm > stumped on the error message handling from clean(). > > I

Multiple validation error handling in clean()

2008-02-14 Thread robstar
Hi guys, I'm working my way through the newforms and it's pretty cool.. but I'm stumped on the error message handling from clean(). I want to check the CAPTCHA input on the page (2 fields) as well as if the password fields match and return the error for each problem independently. clean() is sup

suggestion for sql error handling

2007-07-22 Thread Andrey Khavryuchenko
Hi! Sometimes we all get sql errors from our code. Nevertheless the traceback kind of File "/usr/lib/python2.4/site-packages/django/db/models/query.py", line 242, in count cursor.execute("SELECT COUNT(*)" + sql, params) File "/usr/lib/python2.4/site-packages/django/db/backends/util.py"

Re: Error Handling

2007-06-09 Thread Malcolm Tredinnick
On Sat, 2007-06-09 at 22:13 +, Christopher wrote: > Is there a way that I can do something like this in Python? > > try: > # Do something > except not MyModel.DoesNotExist: > # Handle it... > > I want to handle all exception except if it's a DoesNotExist one. > Then I don't care. This w

Error Handling

2007-06-09 Thread Christopher
Is there a way that I can do something like this in Python? try: # Do something except not MyModel.DoesNotExist: # Handle it... I want to handle all exception except if it's a DoesNotExist one. Then I don't care. --~--~-~--~~~---~--~~ You received this messa

Re: newbie : Django Error Handling

2007-03-22 Thread Malcolm Tredinnick
On Thu, 2007-03-22 at 12:53 +0100, sebastien Pastor wrote: > Coming back to the topic. Will i be safe if i surround my SQL-related > code with mySQLDb exceptions? As i understood that doing some tests that > those are the exceptions raised by django. > > Can anyone confirm this ? Or point me to

Re: newbie : Django Error Handling

2007-03-22 Thread sebastien Pastor
Coming back to the topic. Will i be safe if i surround my SQL-related code with mySQLDb exceptions? As i understood that doing some tests that those are the exceptions raised by django. Can anyone confirm this ? Or point me to another directions to handle SQL exceptions properly if there is so

Re: newbie : Django Error Handling

2007-03-21 Thread sebastien Pastor
Hi Simon, Thanks for your response! I was more thinking of exceptions raised when something is terribly wrong like mysql being down when you try to do a : Models.objects.all() or maybe also if you try to fetch data filtering with a filter with a wrong data type. ... basically every excepti

Re: newbie : Django Error Handling

2007-03-21 Thread [EMAIL PROTECTED]
Hi Seb :) There's no list of exceptions in the docs, but if other people think it's a good idea, I'll add it as a feature request. Anyway, Models.objects.all() will return an empty list ([]) if there's nothing in the database. Something like Model.objects.get(pk=somevalue) will raise a Models.Do

newbie : Django Error Handling

2007-03-21 Thread seb
Hi All, This is my very first POST. I am looking @ django for a quick project i have to set up; and so far i must admit i am quite amazed on how quickly things can be done. One thing bugs me though i could not find anywhere how to handle errors : what are the exceptions thrown by django for insta

Re: Testing and error handling

2007-03-08 Thread Lawrence Oluyede
> Can you provide a few more clues, please? In particular, what exception > is being raised. If we know what part of the code is involved, it will > be easier to try and work out the differences. > If you can reduce the behaviour to a simple (only a few lines) example, > that would be great, too.

Re: Testing and error handling

2007-03-07 Thread Malcolm Tredinnick
On Wed, 2007-03-07 at 02:24 -0800, Lawrence Oluyede wrote: > I'm having some problems with the same codebase tested with Python 2.5 > and previous versions. With Python 2.5 the tests pass smoothly but > with 2.4 and 2.3 they "explode". The problem seems to arise when the > application raises an ex

Testing and error handling

2007-03-07 Thread Lawrence Oluyede
I'm having some problems with the same codebase tested with Python 2.5 and previous versions. With Python 2.5 the tests pass smoothly but with 2.4 and 2.3 they "explode". The problem seems to arise when the application raises an exception due to bad behavior. Python 2.5 gets back a HTTP 500 (that

Re: Database Error Handling

2007-01-24 Thread Tim Chase
> The other would be to catch the database error and then validate > again. But in the meantime, something else could have happened, so > you end up with a structure like this: > > for i in range(settings.RETRIES) > ... validate ... > try: > ... save ... > break > except ... > ..

Re: Database Error Handling

2007-01-24 Thread Vadim Macagon
Michael Radziej wrote: > That's a good spot. > > It's hard to impossible to catch the error and figure out what the > error message means, since there's no real standard how these error > messages look like. All you got is a string ... > > One way to do this is to lock the table Post before vali

Re: Database Error Handling

2007-01-24 Thread Michael Radziej
Vadim Macagon: > ... > Let's say I have a Post model with a title field, that title must be > unique for a given date. Here's a sequence of events that could > potentially happen: > > time: t1). User A fills in a form to create a new Post, and sets the > title to "Donkeys". > time: t2). User B

Re: Database Error Handling

2007-01-23 Thread Vadim Macagon
[EMAIL PROTECTED] wrote: > In production mode all my errors are mailed to me. So I obviously see > what happen. This works fine for most errors but not for IntegrityError(s) you can recover from, in that case by the time you get the email it's already too late to do anything about it. Let's s

Re: Database Error Handling

2007-01-22 Thread [EMAIL PROTECTED]
Hi Vadim, > Am I just taking the wrong approach here or something? Considering how > few questions I found regarding this it would appear that most people > are either blissfully ignoring db errors or know something I don't :) Probably. At least I never thought about wrapping save method with tr

Database Error Handling

2007-01-22 Thread Vadim Macagon
There have been some questions in the past about how to catch IntegrityError(s) thrown by Model.save(), and there were two options suggested: 1). Don't wrap Model.save() in a try/except, because the data should be valid before saving. I validate the data before saving, but if validation occur