[Django] #12163: Regression: Pickling error saving session with unsaved model instances (*_Deferred_)

View: New views
7 Messages — Rating Filter:   Alert me  

[Django] #12163: Regression: Pickling error saving session with unsaved model instances (*_Deferred_)

by noreply-71 :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

#12163: Regression: Pickling error saving session with unsaved model instances
(*_Deferred_)
--------------------------------------------------------+-------------------
 Reporter:  rfugger                                     |       Owner:  nobody    
   Status:  new                                         |   Milestone:            
Component:  Database layer (models, ORM)                |     Version:  SVN      
 Keywords:  pickle, session, model, instance, deferred  |       Stage:  Unreviewed
Has_patch:  0                                           |  
--------------------------------------------------------+-------------------
 When attempting to store freshly-created unsaved model instances in a
 session, I get the following error:

 {{{
 PicklingError: Can't pickle <class 'order.models.OrderItem_Deferred_'>:
 attribute lookup order.models.OrderItem_Deferred_ failed
 }}}

 The object is an instance of !OrderItem.  Apparently django instantiates
 it as !OrderItem_Deferred_, and then pickle can't deal with it?

 Using svn revision 11723.  Worked fine in 11616.

--
Ticket URL: <http://code.djangoproject.com/ticket/12163>
Django <http://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 post to this group, send email to django-updates@...
To unsubscribe from this group, send email to django-updates+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: [Django] #12163: Regression: Pickling error saving session with unsaved model instances (*_Deferred_)

by noreply-71 :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

#12163: Regression: Pickling error saving session with unsaved model instances
(*_Deferred_)
---------------------------------------------------+------------------------
          Reporter:  rfugger                       |         Owner:  nobody                                    
            Status:  new                           |     Milestone:  1.2                                      
         Component:  Database layer (models, ORM)  |       Version:  SVN                                      
        Resolution:                                |      Keywords:  pickle, session, model, instance, deferred
             Stage:  Unreviewed                    |     Has_patch:  0                                        
        Needs_docs:  0                             |   Needs_tests:  0                                        
Needs_better_patch:  0                             |  
---------------------------------------------------+------------------------
Changes (by russellm):

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

Comment:

 There have been some recent changes to the infrastructure around pickling
 of deferred fields - evidently you have found a case that wasn't covered
 by our test suite.

 Can you please provide a complete test case - i.e., a minimal set of
 models, and the exact sequence of commands that fails.

--
Ticket URL: <http://code.djangoproject.com/ticket/12163#comment:1>
Django <http://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 post to this group, send email to django-updates@...
To unsubscribe from this group, send email to django-updates+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: [Django] #12163: Regression: Pickling error saving session with unsaved model instances (*_Deferred_)

by noreply-71 :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

#12163: Regression: Pickling error saving session with unsaved model instances
(*_Deferred_)
---------------------------------------------------+------------------------
          Reporter:  rfugger                       |         Owner:  nobody                                    
            Status:  new                           |     Milestone:  1.2                                      
         Component:  Database layer (models, ORM)  |       Version:  SVN                                      
        Resolution:                                |      Keywords:  pickle, session, model, instance, deferred
             Stage:  Unreviewed                    |     Has_patch:  0                                        
        Needs_docs:  0                             |   Needs_tests:  0                                        
Needs_better_patch:  0                             |  
---------------------------------------------------+------------------------
Comment (by rfugger):

 I'll try to work up a test case when I have time.  Strangely, when I
 reverted to r11616, the `__reduce__` function was broken (`model` used
 before assignment), even though it was definitely working fine three days
 ago.  So maybe I'm doing something wrong, although I don't think my
 surrounding code has changed since then.

 In the meantime, replacing `model = self.__class__` with `model =
 self._meta.proxy_for_model` near the start of
 `db.models.base.Model.__reduce__` seems to fix the issue for me.  I'm not
 sure if this is a good general solution or not, because I don't really
 know how deferred fields work.

--
Ticket URL: <http://code.djangoproject.com/ticket/12163#comment:2>
Django <http://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 post to this group, send email to django-updates@...
To unsubscribe from this group, send email to django-updates+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: [Django] #12163: Regression: Pickling error saving session with unsaved model instances (*_Deferred_)

by noreply-71 :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

#12163: Regression: Pickling error saving session with unsaved model instances
(*_Deferred_)
---------------------------------------------------+------------------------
          Reporter:  rfugger                       |         Owner:  nobody                                    
            Status:  new                           |     Milestone:  1.2                                      
         Component:  Database layer (models, ORM)  |       Version:  SVN                                      
        Resolution:                                |      Keywords:  pickle, session, model, instance, deferred
             Stage:  Unreviewed                    |     Has_patch:  0                                        
        Needs_docs:  0                             |   Needs_tests:  0                                        
Needs_better_patch:  0                             |  
---------------------------------------------------+------------------------
Comment (by rfugger):

 (Sorry, probably better not to replace `model = self.__class__`, but just
 to set `model = self._meta.proxy_for_model` as a default when
 `self._deferred` is True.

--
Ticket URL: <http://code.djangoproject.com/ticket/12163#comment:3>
Django <http://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 post to this group, send email to django-updates@...
To unsubscribe from this group, send email to django-updates+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: [Django] #12163: Regression: Pickling error saving session with unsaved model instances (*_Deferred_)

by noreply-71 :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

#12163: Regression: Pickling error saving session with unsaved model instances
(*_Deferred_)
---------------------------------------------------+------------------------
          Reporter:  rfugger                       |         Owner:  nobody                                    
            Status:  new                           |     Milestone:  1.2                                      
         Component:  Database layer (models, ORM)  |       Version:  SVN                                      
        Resolution:                                |      Keywords:  pickle, session, model, instance, deferred
             Stage:  Unreviewed                    |     Has_patch:  0                                        
        Needs_docs:  0                             |   Needs_tests:  0                                        
Needs_better_patch:  0                             |  
---------------------------------------------------+------------------------
Changes (by rfugger):

 * cc: arv@... (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/12163#comment:4>
Django <http://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 post to this group, send email to django-updates@...
To unsubscribe from this group, send email to django-updates+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: [Django] #12163: Regression: Pickling error saving session with unsaved model instances (*_Deferred_)

by noreply-71 :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

#12163: Regression: Pickling error saving session with unsaved model instances
(*_Deferred_)
---------------------------------------------------+------------------------
          Reporter:  rfugger                       |         Owner:  nobody                                    
            Status:  new                           |     Milestone:  1.2                                      
         Component:  Database layer (models, ORM)  |       Version:  SVN                                      
        Resolution:                                |      Keywords:  pickle, session, model, instance, deferred
             Stage:  Unreviewed                    |     Has_patch:  0                                        
        Needs_docs:  0                             |   Needs_tests:  0                                        
Needs_better_patch:  0                             |  
---------------------------------------------------+------------------------
Comment (by AndrewIngram):

 I'd just like to add that it's revision 11691 that causes this, using
 11690 should fix things for now.

--
Ticket URL: <http://code.djangoproject.com/ticket/12163#comment:5>
Django <http://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 post to this group, send email to django-updates@...
To unsubscribe from this group, send email to django-updates+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: [Django] #12163: Regression: Pickling error saving session with unsaved model instances (*_Deferred_)

by noreply-71 :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

#12163: Regression: Pickling error saving session with unsaved model instances
(*_Deferred_)
---------------------------------------------------+------------------------
          Reporter:  rfugger                       |         Owner:  nobody                                    
            Status:  new                           |     Milestone:  1.2                                      
         Component:  Database layer (models, ORM)  |       Version:  SVN                                      
        Resolution:                                |      Keywords:  pickle, session, model, instance, deferred
             Stage:  Unreviewed                    |     Has_patch:  0                                        
        Needs_docs:  0                             |   Needs_tests:  0                                        
Needs_better_patch:  0                             |  
---------------------------------------------------+------------------------
Comment (by rfugger):

 Thanks Andrew.  r11690 does work.  I hadn't cleared out my session last
 time I tried a pre-11691 revision, so pickled *_Deferred_ objects were
 still hanging around and causing errors.

--
Ticket URL: <http://code.djangoproject.com/ticket/12163#comment:6>
Django <http://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 post to this group, send email to django-updates@...
To unsubscribe from this group, send email to django-updates+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---