On Dec 16, 2007, at 3:16 PM, [EMAIL PROTECTED] wrote:

>
>>> not sure what the three get_history sublists are for...
>>
>>
>> (added, unchanged, deleted) =
>> attributes.get_history(myinstance._state, 'someattribute')
>>
>> three lists will never be None unless you call get_history() with
>> passive=True and lazyload would be needed.
> in a scalar context, what (added, unchanged, deleted) mean?
> setattr->added
> delattr->deleted
> ? so the old value is (deleted or unchanged)[0]?

i have really nice unit tests now that illustrate the whole thing in  
test/orm/attributes.py HistoryTest:

         attributes.register_class(Foo)
         attributes.register_attribute(Foo, 'someattr', uselist=False,  
useobject=False)

         f = Foo()
         self.assertEquals(attributes.get_history(f._state,  
'someattr'), ([], [], []))

         f.someattr = "hi"
         self.assertEquals(attributes.get_history(f._state,  
'someattr'), (['hi'], [], []))

         f._state.commit(['someattr'])
         self.assertEquals(attributes.get_history(f._state,  
'someattr'), ([], ['hi'], []))

         f.someattr = 'there'

         self.assertEquals(attributes.get_history(f._state,  
'someattr'), (['there'], [], ['hi']))
         f._state.commit(['someattr'])

         self.assertEquals(attributes.get_history(f._state,  
'someattr'), ([], ['there'], []))

         del f.someattr   # oops, svn up to r3952
         self.assertEquals(attributes.get_history(f._state,  
'someattr'), ([], [], ['there']))

if the attribute is an object reference, you might have [None] instead  
of [] for added/unchanged if theres no value.



--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to