On May 18, 2007, at 12:00 PM, Glauco wrote:

>
> i all my mapper i use this property frequently:
>
>     @property
>     def changed(self):
>         return self._state.get('modified')
>

_state is not public and is not always going to be set, and does not  
account for "mutable" properties like pickled types.  a better way is  
to say "obj in session.dirty".

> but in some cases ( 1:n relation ) mapper this don't work:
>
>
> In [1]: o =Operatore.select()[4]
>
> In [2]: o._state.get('modified')
> Out[2]: False
>
> In [3]: o.groups[0].acl_cod_ruolo
> Out[3]: u'VET'
>
> In [4]: o.groups[0].acl_cod_ruolo = '123'
>
> In [5]: o.groups[0].acl_cod_ruolo
> Out[5]: '123'
>
> In [6]: o.groups[0]._state.get('modified')
> Out[6]: True
>
> In [7]: o._state.get('modified')
> Out[7]: False
>
>
>
> Why the parent self._state['modified'] don't get the changes from  
> childs
> mappers sometimes?
> i'm doing something wrong?

_state gets set as the result of a change event on the instance.  it  
doesnt get propigated to parent instances though, there shouldnt be  
any case that this happens.  you may observe it occuring as the  
result of a bi-directional relationship in some cases.  above you are  
changing the instance at o.groups[0], but that has no effect on "o".


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

Reply via email to