class NovaObject:
- # Set this to a dict of the valid fields of this object and their
- # types. Not all fields (e.g., joined fields) may be updated via
- # sync().
- @staticmethod
+ @staticmethod
def object_to_dict(object, fields):
d = {}
for field in fields:
if hasattr(object, field):
d[field] = getattr(object, field)
- return d
+ return d
+
+
+class NovaObjects(list):
+ fields = {}
+
+ def dicts(self):
+ result = []
+ for obj in self:
+ result.append(NovaObject.object_to_dict(obj, self.fields))
+ return result