Glauco wrote:
> jo ha scritto:
>   
>> Michael Bayer ha scritto:
>>   
>>     
>>> that is your own application changing the primary key of a loaded  
>>> instance, which is a feature very old versions of SQLAlchemy did not  
>>> support.  Upgrade to any recent version of 0.4 or 0.5 and you wont  
>>> have that issue anymore.
>>>   
>>>     
>>>       
>> I think I don't want to change this behavior , Michael,
>> Simply I would like to realize that changes was done at current loaded 
>> instance
>> to avoid flush it.
>>
>>   
>>     
> <cut>
>
> Yes you have it,
> cls._state['original'].data
>
> but probably you must work over object stored in session
>
>
> Gla
>   

cls._state['original'].data returns the instance data.

What I need instead is how to retrieve
the value of 'existing identity' and 'new identity' to compare them before
sa raises the exception FlushError.

Something like:

if  obj._instance_key <> instance_key:  do_not_flush

to avoid the following error:

raise exceptions.FlushError("Can't change the identity of instance %s in 
session (existing identity: %s; new identity: %s)" % 
(mapperutil.instance_str(obj), obj._instance_key, instance_key))
FlushError: Can't change the identity of instance spe...@0xa6e046c in 
session (existing identity: (<class 
'sicer.BASE.model.tabelleCodifica.specie.Specie'>, (u'0141',), None); 
new identity: (<class 'sicer.BASE.model.tabelleCodifica.specie.Specie'>, 
(u'08',), None))


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

Reply via email to