Restructure code in preparation for sharing with new TKO.

-Change structure of RPC handler.  New rpc_handler.py is independent of AFE and will eventually be moved to a common dir, along with the JSON and JSON-RPC stuff.  rpc_handler.py now has a class structure that allows multiple apps to instantiate their own RPC handlers with different interfaces.

-Pull out generic model extensions from models.py into model_logic.py.  This too will be moved to a common dir.


git-svn-id: http://test.kernel.org/svn/autotest/trunk@1566 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/frontend/afe/views.py b/frontend/afe/views.py
index e0f74cd..d448215 100644
--- a/frontend/afe/views.py
+++ b/frontend/afe/views.py
@@ -1,8 +1,20 @@
 import urllib2
 
-from frontend.afe import models
+from frontend.afe import models, rpc_handler, rpc_interface, site_rpc_interface
+from frontend.afe import rpc_utils
 from django.http import HttpResponse, HttpResponsePermanentRedirect
 
+# since site_rpc_interface is later in the list, its methods will override those
+# of rpc_interface
+rpc_handler_obj = rpc_handler.RpcHandler((rpc_interface, site_rpc_interface),
+					 document_module=rpc_interface)
+
+
+def handle_rpc(request):
+	rpc_utils.set_user(request.afe_user)
+	return rpc_handler_obj.handle_rpc_request(request)
+
+
 def model_documentation(request):
 	doc = '<h2>Models</h2>\n'
 	for model_name in ('Label', 'Host', 'Test', 'User', 'AclGroup', 'Job'):