Blame SOURCES/cobbler-catch-cheetah-exception.patch

1070a0
diff -ur cobbler.orig/scripts/services.py cobbler/scripts/services.py
1070a0
--- cobbler.orig/scripts/services.py	2012-11-09 17:31:33.000000000 +0100
1070a0
+++ cobbler/scripts/services.py	2012-11-09 17:31:51.000000000 +0100
1070a0
@@ -86,7 +86,12 @@
1070a0
     mode = form.get('op','index')
1070a0
 
1070a0
     func = getattr( cw, mode )
1070a0
-    content = func( **form )
1070a0
+    try:
1070a0
+        content = func( **form )
1070a0
+    except xmlrpclib.Fault, (err):
1070a0
+        req.status = apache.HTTP_INTERNAL_SERVER_ERROR
1070a0
+        req.write(err.faultString)
1070a0
+        return apache.OK
1070a0
 
1070a0
     # apache.log_error("%s:%s ... %s" % (my_user, my_uri, str(form)))
1070a0
     req.content_type = "text/plain;charset=utf-8"
1070a0
diff -ur cobbler.orig/scripts/services.wsgi cobbler/scripts/services.wsgi
1070a0
--- cobbler.orig/scripts/services.wsgi	2012-11-09 17:31:33.000000000 +0100
1070a0
+++ cobbler/scripts/services.wsgi	2012-11-09 17:31:58.000000000 +0100
1070a0
@@ -21,6 +21,7 @@
1070a0
 """
1070a0
 import yaml
1070a0
 import os
1070a0
+import xmlrpclib
1070a0
1070a0
 from cobbler.services import CobblerSvc
1070a0
 import cobbler.utils as utils
1070a0
@@ -75,22 +76,26 @@
1070a0
 
1070a0
     # Execute corresponding operation on the CobblerSvc object:
1070a0
     func = getattr( cw, mode )
1070a0
-    content = func( **form )
1070a0
+    try:
1070a0
+        content = func( **form )
1070a0
 
1070a0
-    content = unicode(content).encode('utf-8')
1070a0
-    status = '200 OK'
1070a0
+        content = unicode(content).encode('utf-8')
1070a0
+        status = '200 OK'
1070a0
+        
1070a0
+        if content.find("# *** ERROR ***") != -1:
1070a0
+            status = '500 SERVER ERROR'
1070a0
+            print("possible cheetah template error")
1070a0
     
1070a0
-    if content.find("# *** ERROR ***") != -1:
1070a0
+        # TODO: Not sure these strings are the right ones to look for...
1070a0
+        elif content.find("# profile not found") != -1 or \
1070a0
+                content.find("# system not found") != -1 or \
1070a0
+                content.find("# object not found") != -1:
1070a0
+            print("content not found: %s" % my_uri)
1070a0
+            status = "404 NOT FOUND"
1070a0
+    except xmlrpclib.Fault, (err):
1070a0
         status = '500 SERVER ERROR'
1070a0
-        print("possible cheetah template error")
1070a0
-
1070a0
-    # TODO: Not sure these strings are the right ones to look for...
1070a0
-    elif content.find("# profile not found") != -1 or \
1070a0
-            content.find("# system not found") != -1 or \
1070a0
-            content.find("# object not found") != -1:
1070a0
-        print("content not found: %s" % my_uri)
1070a0
-        status = "404 NOT FOUND"
1070a0
-
1070a0
+        content = err.faultString
1070a0
+	
1070a0
  #   req.content_type = "text/plain;charset=utf-8"
1070a0
     response_headers = [('Content-type', 'text/plain;charset=utf-8'),
1070a0
                         ('Content-Length', str(len(content)))]