-added capability to have site-specific urlconfs in TKO Django server
-added ClassFactory and SiteClassFactory to autotest.tko package to allow site-specific modifications to TKO.  made some changes to the AFE [Site]ClassFactory files (reducing visibility)
-added get_detailed_test_views RPC which includes information about labels and attributes associated with a test
-made changes to model_logic.py to make fewer assumptions about models.  these were basically bugs in model_logic.py that weren't exposed until i started doing fancier queries on TKO models.
-made list_objects capable of accepting a field list
-changed JsonRpcProxy to contain base URLs instead of full RPC urls; this way, other components (graphing, jlog) can use them (and i made graphing use this URL, which fixes a bug in the embedded URL generation)
-added RealHyperlink widget to common.ui package, representing a plain old hyperlink to another page (as opposed to Hyperlink and SimpleHyperlink, which are intended to be handling by the GWT code).  this eases dynamic updates of the link href and allows setting visibility, styles, and all the other good stuff that comes along with using Widgets.



git-svn-id: http://test.kernel.org/svn/autotest/trunk@2191 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/new_tko/tko/models.py b/new_tko/tko/models.py
index 70802d3..8e5ee3d 100644
--- a/new_tko/tko/models.py
+++ b/new_tko/tko/models.py
@@ -129,7 +129,7 @@
         db_table = 'jobs'
 
 
-class Test(dbmodels.Model):
+class Test(dbmodels.Model, model_logic.ModelExtensions):
     test_idx = dbmodels.IntegerField(primary_key=True)
     job = dbmodels.ForeignKey(Job, db_column='job_idx')
     test = dbmodels.CharField(maxlength=90)
@@ -145,8 +145,10 @@
         db_table = 'tests'
 
 
-class TestAttribute(dbmodels.Model):
-    test = dbmodels.ForeignKey(Test, db_column='test_idx')
+class TestAttribute(dbmodels.Model, model_logic.ModelExtensions):
+    # this isn't really a primary key, but it's necessary to appease Django
+    # and is harmless as long as we're careful
+    test = dbmodels.ForeignKey(Test, db_column='test_idx', primary_key=True)
     attribute = dbmodels.CharField(maxlength=90)
     value = dbmodels.CharField(blank=True, maxlength=300)
 
@@ -155,7 +157,8 @@
 
 
 class IterationAttribute(dbmodels.Model):
-    test = dbmodels.ForeignKey(Test, db_column='test_idx')
+    # see comment on TestAttribute regarding primary_key=True
+    test = dbmodels.ForeignKey(Test, db_column='test_idx', primary_key=True)
     iteration = dbmodels.IntegerField()
     attribute = dbmodels.CharField(maxlength=90)
     value = dbmodels.CharField(blank=True, maxlength=300)
@@ -431,21 +434,12 @@
 
 
     @classmethod
-    def list_objects(cls, filter_data, initial_query=None):
-        """
-        Django's ValuesQuerySet (used when you call query.values()) doesn't
-        support custom select fields, so we have to basically reimplement it
-        here.
-        TODO: merge this up to ModelExtensions after some settling time.
-        """
-        query = cls.query_objects(filter_data, initial_query=initial_query)
-        object_dicts = []
-        for model_object in query:
-            object_dict = model_object.get_object_dict()
-            for sql in cls.extra_fields.iterkeys():
-                object_dict[sql] = getattr(model_object, sql)
-            object_dicts.append(object_dict)
-        return object_dicts
+    def list_objects(cls, filter_data, initial_query=None, fields=None):
+        # include extra fields
+        if fields is None:
+            fields = cls.get_field_dict().keys() + cls.extra_fields.keys()
+        return super(TestView, cls).list_objects(filter_data, initial_query,
+                                                 fields)
 
 
     class Meta: