1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Major refactoring of django.dispatch with an eye towards speed. The net result is that signals are up to 90% faster.

Though some attempts and backwards-compatibility were made, speed trumped compatibility. Thus, as usual, check BackwardsIncompatibleChanges for the complete list of backwards-incompatible changes.

Thanks to Jeremy Dunck and Keith Busell for the bulk of the work; some ideas from Brian Herring's previous work (refs #4561) were incorporated.

Documentation is, sigh, still forthcoming.

Fixes #6814 and #3951 (with the new dispatch_uid argument to connect).


git-svn-id: http://code.djangoproject.com/svn/django/trunk@8223 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jacob Kaplan-Moss
2008-08-06 15:32:46 +00:00
parent d06b474251
commit 34a3bd5225
33 changed files with 380 additions and 848 deletions

View File

@@ -10,7 +10,6 @@ except ImportError:
from django.db import connection, get_creation_module
from django.db.models import signals
from django.db.models.query_utils import QueryWrapper
from django.dispatch import dispatcher
from django.conf import settings
from django.core import validators
from django import oldforms
@@ -819,9 +818,9 @@ class FileField(Field):
setattr(cls, 'get_%s_url' % self.name, curry(cls._get_FIELD_url, field=self))
setattr(cls, 'get_%s_size' % self.name, curry(cls._get_FIELD_size, field=self))
setattr(cls, 'save_%s_file' % self.name, lambda instance, filename, raw_field, save=True: instance._save_FIELD_file(self, filename, raw_field, save))
dispatcher.connect(self.delete_file, signal=signals.post_delete, sender=cls)
signals.post_delete.connect(self.delete_file, sender=cls)
def delete_file(self, instance):
def delete_file(self, instance, **kwargs):
if getattr(instance, self.attname):
file_name = getattr(instance, 'get_%s_filename' % self.name)()
# If the file exists and no other object of this type references it,