|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
django model adapter ?bug? + patchHello list,
I think I've found a potential bug in the the _django_db_models_base.py adapter handler. The problem manifests itself when objects coming from flex are unmarshalled back into python objects and their properties set by the adapter. I'm using django 1.0.2 and it constrains the order a model object's attributes can be set: - The primary key of the object must be set *before* any relationship fields are set If relationship fields are set first, but the primary key is null, django throws an exception. The code for setting the attributes previously took a dictionary of attributes/values and iteritem-ed over them, setting all attributes. For normal objects this works perfectly fine, but for django model objects with relationships, whenever a relationship field is attempted to be set, the primary key field must first be set. I've attached a patch (very simple, like 4 lines of code) to this file that makes sure the primary key field as set first, before any other attributes. This solves the above problem and allows for django object graphs to be sent via pyamf. The patch was created against the release-0.4.2 svn branch. Hope this helps, I can also post this as a ticket, but figured I'd send it out to the mailing list first to make sure it's sane, and see if anyone else has encountered this issue. Thanks! -Mark _______________________________________________ PyAMF users mailing list - users@... http://lists.pyamf.org/mailman/listinfo/users |
|
|
Re: django model adapter ?bug? + patchHi!
On 26 Jun 2009, at 21:12, Mark Mitchell wrote: > Hello list, > > I think I've found a potential bug in the the > _django_db_models_base.py adapter handler. Indeed you have! > > The problem manifests itself when objects coming from flex are > unmarshalled back into python objects and their properties set by the > adapter. I'm using django 1.0.2 and it constrains the order a model > object's attributes can be set: > > - The primary key of the object must be set *before* any > relationship fields are set > > If relationship fields are set first, but the primary key is null, > django throws an exception. The code for setting the attributes > previously took a dictionary of attributes/values and iteritem-ed over > them, setting all attributes. For normal objects this works perfectly > fine, but for django model objects with relationships, whenever a > relationship field is attempted to be set, the primary key field must > first be set. This makes total sense, I have created a ticket with this patch so we can get this into 0.5 [1]. Thanks for taking the time to put the patch together. Cheers, Nick [1] - http://pyamf.org/ticket/599 _______________________________________________ PyAMF users mailing list - users@... http://lists.pyamf.org/mailman/listinfo/users |
| Free embeddable forum powered by Nabble | Forum Help |