ovs.db.idl: Use top-level class to represent IDL rows.
authorBen Pfaff <blp@nicira.com>
Tue, 23 Aug 2011 16:36:39 +0000 (09:36 -0700)
committerBen Pfaff <blp@nicira.com>
Wed, 24 Aug 2011 18:57:43 +0000 (11:57 -0700)
According to Reid, there may be some disadvantages to having this class be
anonymous, for example, cannot do instance/typechecking, might be
allocating a new class for every row as well, which isn't the most memory
efficient.

Suggested-by: Reid Price <reid@nicira.com>
python/ovs/db/idl.py

index abb7a444a438c7cba2fed672b28a694f9184831a..dc5f89e69bbcb66bb77fcaa3f615a0616bb676db 100644 (file)
@@ -293,8 +293,6 @@ class Idl:
             self.data[table_name] = {}
 
     def __create_row(self, table, uuid):
-        class Row(object):
-            pass
         row = self.data[table.name][uuid] = Row()
         for column in table.columns.itervalues():
             setattr(row, column.name, ovs.db.data.Datum.default(column.type))
@@ -304,3 +302,10 @@ class Idl:
         """Forces the IDL to drop its connection to the database and reconnect.
         In the meantime, the contents of the IDL will not change."""
         self.session.force_reconnect()
+
+class Row(object):
+    """A row within an Idl.  Data for each column is stored as an attribute
+    with the same name as the column and using an ovs.db.data.Datum as the
+    value."""
+    pass
+