On 5/30/07, Robert Coup <[EMAIL PROTECTED]> wrote: > Why not connect to pre_save and check whether the primary key is None, > similar to the accepted way to check for creation if you override > Model.save()?
Forest already mentioned not knowing if the object persistence will be successful. In many cases using transactions will rollback any changes that happen if a problem pops-up later (assuming those changes are in the database). Another problem is with OneToOne relations. The primary key will be populated prior to save. Internally, Django solves this by querying the database to see if the object already exists. It would be possible to replicate this in a pre_save listener, but the result would be hitting the DB with three queries instead of the current two (and it's possible to do it with one -- see prior discussions about explicit .insert() and .update() methods). I'm +1 for adding a post_create signal to core. I've already implemented both pre_create and post_create on my own without too much hassle though. Also wanted to point out the fact that there is an existing ticket in the 'design decision needed' stage of its life-cycle. Same concept, just different naming. [0] - Ben [0] http://code.djangoproject.com/ticket/2154 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---