Browse files

Companion checkin to [432]

git-svn-id: http://code.djangoproject.com/svn/django/trunk@433 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent b7e5121 commit a90e9f43db394565502c040502d8a4421767ba0b @adrianholovaty adrianholovaty committed Aug 8, 2005
Showing with 7 additions and 1 deletion.
  1. +6 −0 django/core/meta/__init__.py
  2. +1 −1 tests/testapp/models/__init__.py
View
6 django/core/meta/__init__.py
@@ -756,6 +756,9 @@ def method_save(opts, self):
def method_delete(opts, self):
assert getattr(self, opts.pk.name) is not None, "%r can't be deleted because it doesn't have an ID."
+ # Run any pre-delete hooks.
+ if hasattr(self, '_pre_delete'):
+ self._pre_delete()
cursor = db.db.cursor()
for rel_opts, rel_field in opts.get_all_related_objects():
rel_opts_name = opts.get_rel_object_method_name(rel_opts, rel_field)
@@ -782,6 +785,9 @@ def method_delete(opts, self):
# delete it from the filesystem.
if os.path.exists(file_name) and not opts.get_model_module().get_list(**{'%s__exact' % f.name: getattr(self, f.name)}):
os.remove(file_name)
+ # Run any post-delete hooks.
+ if hasattr(self, '_post_delete'):
+ self._post_delete()
def method_get_next_in_order(opts, order_field, self):
if not hasattr(self, '_next_in_order_cache'):
View
2 tests/testapp/models/__init__.py
@@ -1,3 +1,3 @@
__all__ = ['basic', 'repr', 'custom_methods', 'many_to_one', 'many_to_many',
'ordering', 'lookup', 'get_latest', 'm2m_intermediary', 'one_to_one',
- 'm2o_recursive', 'm2o_recursive2']
+ 'm2o_recursive', 'm2o_recursive2', 'save_delete_hooks']

0 comments on commit a90e9f4

Please sign in to comment.