« Return to Thread: django model adapter ?bug? + patch

Re: django model adapter ?bug? + patch

by Nick Joyce :: Rate this Message:

Reply to Author | View in Thread

Hi!

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

 « Return to Thread: django model adapter ?bug? + patch