Re: [Django] #13784: pre_save is dispatched before executing upload_to attributes on FileFields when using ModelForm

2010-06-18 Thread Django
#13784: pre_save is dispatched before executing upload_to attributes on 
FileFields
when using ModelForm
-+--
  Reporter:  peterbe | Owner:  nobody
Status:  closed  | Milestone:
 Component:  Forms   |   Version:  1.2   
Resolution:  duplicate   |  Keywords:  ModelForm pre_save
 Stage:  Unreviewed  | Has_patch:  0 
Needs_docs:  0   |   Needs_tests:  0 
Needs_better_patch:  0   |  
-+--
Comment (by peterbe):

 Oh I see. I really did google the tickets but didn't find that one.

 Personally thinks it sucks but will keep my mouth shut till I provide a
 patch of my own :)

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #13784: pre_save is dispatched before executing upload_to attributes on FileFields when using ModelForm

2010-06-17 Thread Django
#13784: pre_save is dispatched before executing upload_to attributes on 
FileFields
when using ModelForm
-+--
  Reporter:  peterbe | Owner:  nobody
Status:  closed  | Milestone:
 Component:  Forms   |   Version:  1.2   
Resolution:  duplicate   |  Keywords:  ModelForm pre_save
 Stage:  Unreviewed  | Has_patch:  0 
Needs_docs:  0   |   Needs_tests:  0 
Needs_better_patch:  0   |  
-+--
Changes (by kmtracey):

  * status:  new => closed
  * resolution:  => duplicate

Comment:

 This behavior got a fair amount of discussion when it was introduced. See
 #10788 and the linked threads on django-developers.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #13784: pre_save is dispatched before executing upload_to attributes on FileFields when using ModelForm

2010-06-17 Thread Django
#13784: pre_save is dispatched before executing upload_to attributes on 
FileFields
when using ModelForm
-+--
  Reporter:  peterbe | Owner:  nobody
Status:  new | Milestone:
 Component:  Forms   |   Version:  1.2   
Resolution:  |  Keywords:  ModelForm pre_save
 Stage:  Unreviewed  | Has_patch:  0 
Needs_docs:  0   |   Needs_tests:  0 
Needs_better_patch:  0   |  
-+--
Changes (by peterbe):

  * needs_better_patch:  => 0
  * needs_tests:  => 0
  * needs_docs:  => 0

Comment:

 I suspect that the culprit is {{{Model.save_base}}} in
 {{{django/db/models/base.py}}} where it dispatches the signal before it
 does whatever it does to those {{{meta.local_files}}} but I don't
 understand the code enough to attempt a patch at this point.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



[Django] #13784: pre_save is dispatched before executing upload_to attributes on FileFields when using ModelForm

2010-06-17 Thread Django
#13784: pre_save is dispatched before executing upload_to attributes on 
FileFields
when using ModelForm
+---
 Reporter:  peterbe |   Owner:  nobody
   Status:  new |   Milestone:
Component:  Forms   | Version:  1.2   
 Keywords:  ModelForm pre_save  |   Stage:  Unreviewed
Has_patch:  0   |  
+---
 Suppose you have this code:

 {{{
 def callable_upload_to(instance, filename):
 full_path = os.path.join(this_year(), filename)
 print "PLACING", full_path
 return full_path

 class Foo(models.Model):
 file = models.FileField(upload_to=callable_upload_to)
 size = models.IntegerField(null=True)

 def update_foo(sender, instance, **kwargs):
 print "UPDATING", str(instance.file)

 pre_save.connect(update_foo, sender=Foo)
 }}}

 Suppose you create one of these instances with a '''!ModelForm''' you'll
 get this output on stdout:
 {{{
 UPDATING sample.file
 PLACING 2010/sample.file
 }}}

 That means that you can't rely on the file path as dictated by the
 upload_to callable in your pre_save signal. Especially important is that
 within your {{{pre_save}}} method you can't even get to the file since it
 doesn't exist.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.