magic-removal: Removed _pre_save(), _post_save(), _pre_delete() and _post_delete() hooks. Just subclass the save() and delete() methods now.
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2038 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
51d2de6a56
commit
6e8d06572a
|
@ -118,7 +118,7 @@ class Model(object):
|
|||
|
||||
def _prepare(cls):
|
||||
# Creates some methods once self._meta has been populated.
|
||||
opts = cls._meta
|
||||
opts = cls._meta
|
||||
opts._prepare(cls)
|
||||
|
||||
if opts.order_with_respect_to:
|
||||
|
@ -137,9 +137,6 @@ class Model(object):
|
|||
_prepare = classmethod(_prepare)
|
||||
|
||||
def save(self):
|
||||
# Run any pre-save hooks.
|
||||
if hasattr(self, '_pre_save'):
|
||||
self._pre_save()
|
||||
dispatcher.send(signal=signals.pre_save, sender=self.__class__, instance=self)
|
||||
|
||||
non_pks = [f for f in self._meta.fields if not f.primary_key]
|
||||
|
@ -187,9 +184,6 @@ class Model(object):
|
|||
# Run any post-save hooks.
|
||||
dispatcher.send(signal=signals.pre_save, sender=self.__class__, instance=self)
|
||||
|
||||
if hasattr(self, '_post_save'):
|
||||
self._post_save()
|
||||
|
||||
save.alters_data = True
|
||||
|
||||
def __get_pk_val(self):
|
||||
|
@ -240,9 +234,6 @@ class Model(object):
|
|||
|
||||
# Run any pre-delete hooks.
|
||||
if do_delete:
|
||||
if hasattr(instance, '_pre_delete'):
|
||||
instance._pre_delete()
|
||||
|
||||
dispatcher.send(signal=signals.pre_delete, sender=cls, instance=instance)
|
||||
|
||||
for related in cls._meta.get_all_related_many_to_many_objects():
|
||||
|
@ -276,9 +267,6 @@ class Model(object):
|
|||
|
||||
dispatcher.send(signal=signals.post_delete, sender=cls, instance=instance)
|
||||
|
||||
if hasattr(instance, '_post_delete'):
|
||||
instance._post_delete()
|
||||
|
||||
connection.commit()
|
||||
|
||||
delete.alters_data = True
|
||||
|
|
|
@ -1022,25 +1022,6 @@ A few object methods have special meaning:
|
|||
It's good practice to use ``get_absolute_url()`` in templates, instead of
|
||||
hard-coding your objects' URLs.
|
||||
|
||||
``_pre_save``
|
||||
This method is called just before an object is saved to the database. For
|
||||
example, you can use it to calculate aggregate values from other fields
|
||||
before the object is saved.
|
||||
|
||||
See `Adding hooks before/after saving and deleting`_ for a full example.
|
||||
|
||||
.. _Adding hooks before/after saving and deleting: http://www.djangoproject.com/documentation/models/save_delete_hooks/
|
||||
|
||||
``_post_save``
|
||||
This method is called just after the object is saved to the database. This
|
||||
could be used to update other tables, update cached information, etc.
|
||||
|
||||
``_pre_delete``
|
||||
Like ``_pre_save``, but for deletion.
|
||||
|
||||
``_post_delete``
|
||||
Like ``_post_save``, but for deletion.
|
||||
|
||||
Module-level methods
|
||||
--------------------
|
||||
|
||||
|
|
Loading…
Reference in New Issue