#34517: ImageField unnecessarily adds a post_init signal handler to the model
-------------------------------------+-------------------------------------
     Reporter:  Orhan Hirsch         |                    Owner:  Orhan
         Type:                       |  Hirsch
  Cleanup/optimization               |                   Status:  closed
    Component:  Database layer       |                  Version:  4.2
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  fixed
     Keywords:                       |             Triage Stage:  Ready for
                                     |  checkin
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

 In [changeset:"bcacc6321ae819965f478bfee2072a796801f298" bcacc63]:
 {{{
 #!CommitTicketReference repository=""
 revision="bcacc6321ae819965f478bfee2072a796801f298"
 Refs #34517 -- Restored skipping ImageFileField.update_dimension_fields
 without width/height fields.

 This avoids reading the image size when the dimensions fields
 (image_width, image_height) do not exist, as that operation may be
 expensive.

 Partially reverts ea53e7c09f1b8864c20c65976bbeaeab77abdaec, that dropped
 the check for the dimension fields in update_dimension_fields(), because
 the post_init signal was no longer registered without dimension fields.

 However, another code path to that function exists: when the
 ImageFileField is save()d, the name from the storage is setattr()ed on
 the field, and ImageFileDescriptor calls update_dimension_fields()
 because the image size might have changed. Keep bailing out early when
 dimensions are unused.

 Besides, computing the image dimensions causes to close() the file,
 resulting in a backward-incompatible change. The test protects against
 that change.
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34517#comment:7>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070188d1d6fe36-3c7e9299-f466-4978-a14b-8418f68ed5b5-000000%40eu-central-1.amazonses.com.

Reply via email to