My favorites | Sign in
Project Logo
                
New issue | Search
for
| Advanced search | Search tips
Issue 5: Serialize Class Inheritance
2 people starred this issue and may be notified of changes. Back to list
Status:  New
Owner:  ----
Type-Defect
Priority-Medium


Sign in to add a comment
 
Reported by Flashing...@gmail.com, Apr 30, 2009
Attached a svn diff that adds serialization to subclasses of non-abstract
models.


wadofstuffdiff
11.2 KB   Download
Comment 1 by mattimustang, Apr 30, 2009
Please resubmit the patch so that it doesn't reformat/re-style other parts of the
code e.g.

-    def __init__(self, *args, **kwargs):
+    def __init__( self, *args, **kwargs ):

Comment 2 by Flashing...@gmail.com, May 01, 2009
Oopsala, didn't realize that, sorry. Here you go.

wadofstuffdiff
2.1 KB   Download
Comment 3 by naranjo.manuel, Oct 14, 2009
This is another approach of the patch, with subclass support.

Subclass works by going through the tree until we reach the real node. It's not an
efficient method because you have to hit the database lots of times per object. I
prefer doing something like:

def getRemoteDeviceIterator():
    classes = [ RemoteBluetoothDeviceFoundRecord, 
                RemoteBluetoothDeviceSDP,         
                RemoteBluetoothDeviceNoSDP,       
                RemoteBluetoothDeviceSDPTimeout,  
                RemoteBluetoothDeviceFileTry,     
                RemoteBluetoothDeviceFilesRejected, 
                RemoteBluetoothDeviceFilesSuccess   
        ]                                           
    a=list()                                        
    for b in classes:                               
        a.append(b.objects.filter(agentdevicerecord__commited=False).all())
    for clas in a:                                                         
        for element in clas:                                               
            yield element

because the list(QuerySet..)+list(QuerySet...) hits the database when you do the call
and gets you a lot of stuff in memory.

This patch also adds all the fields that are serializable not just the local_fields,
fields includes the parent class fields so there's no need for doing the weird things
from the previous patch.

I've tested the patch on lab, and going to do deployment tomorrow. Wanted to let you
guys know of it just in case.

Keep the good work,
Manuel

ps: With this patch I'm able to send the subclass and get it deserialized with django
serializer on the other end. The only thing I need to make sure is that the
ForeignKeys or M2M are there before I call save
wadofstuff__subclass.patch
4.7 KB   Download
Sign in to add a comment

Hosted by Google Code