Yes, I agree. 

Actually, I am trying to infer what the "programming model" for this is as we 
go along. 

Personally I would have been happy with only marking the fields when they are 
set. Then, if a you want to change a list somehow you would get it and then set 
it again, e.g.: 
  mylist = object.alist 
  do something to mylist
  object.alist = mylist
  object.save()

Having said that, it can be convenient to use the data structures in place. In 
which case we need all these means to track the changes and they should go in 
the base classes so they are used consistently.

So in short, I am happy with your dirty children :)

Paul.

-----Original Message-----
From: Dan Smith [mailto:[email protected]] 
Sent: 13 January 2014 15:26
To: Murray, Paul (HP Cloud Services); Wang, Shane; OpenStack Development 
Mailing List (not for usage questions)
Cc: Lee, Alexis; Tan, Lin
Subject: Re: [Nova] Detect changes in object model

> ObjectListBase has a field called objects that is typed 
> fields.ListOfObjectsField('NovaObject'). I can see methods for count 
> and index, and I guess you are talking about adding a method for "are 
> any of your contents changed" here. I don't see other list operations 
> (like append, insert, remove, pop) that modify the list. If these were 
> included they would have to mark the list as changed so it is picked 
> up when looking for changes.
> 
> Do you see these belonging here or would you expect those to go in a 
> sub-class if they were wanted?

Well, I've been trying to avoid implying the notion that a list of things 
represents the content of the database. Meaning, I don't think it makes sense 
for someone to get a list of Foo objects, add another Foo to the list and then 
call save() on the list. I think that ends up with the assumption that the list 
matches the contents of the database, and if I add or remove things from the 
list, I can save() the contents to the database atomically. That definitely 
isn't something we can or would want to support.

That said, if we make the parent object consider the child to be dirty if any 
of its contents are dirty or the list itself is dirty (i.e. the list of objects 
has changed) that should give us the desired behavior for change tracking, 
right?

--Dan

_______________________________________________
OpenStack-dev mailing list
[email protected]
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev

Reply via email to