Drop media_data_table property.
authorElrond <elrond+mediagoblin.org@samba-tng.org>
Fri, 1 Feb 2013 15:33:53 +0000 (16:33 +0100)
committerElrond <elrond+mediagoblin.org@samba-tng.org>
Fri, 1 Feb 2013 21:02:35 +0000 (22:02 +0100)
Only when creating a new media_data row, we need the table.
So load that locally in media_data_init().

mediagoblin/db/models.py

index bdd957ddb713523bdef420c3cf84edf724a56f53..c9bc3c1139619f0ab92e35a4a0ff4670b1f16e8b 100644 (file)
@@ -213,9 +213,10 @@ class MediaEntry(Base, MediaEntryMixin):
         media_data = self.media_data
 
         if media_data is None:
+            # Get the correct table:
+            table = import_component(self.media_type + '.models:DATA_MODEL')
             # No media data, so actually add a new one
-            media_data = self.media_data_table(
-                **kwargs)
+            media_data = table(**kwargs)
             # Get the relationship set up.
             media_data.get_media_entry = self
         else:
@@ -223,10 +224,6 @@ class MediaEntry(Base, MediaEntryMixin):
             for field, value in kwargs.iteritems():
                 setattr(media_data, field, value)
 
-    @memoized_property
-    def media_data_table(self):
-        return import_component(self.media_type + '.models:DATA_MODEL')
-
     @memoized_property
     def media_data_ref(self):
         return import_component(self.media_type + '.models:BACKREF_NAME')