File catch_cheetah_exception.patch of Package cobbler

Index: cobbler-2.4.0/bin/services.py
===================================================================
--- cobbler-2.4.0.orig/bin/services.py
+++ cobbler-2.4.0/bin/services.py
@@ -24,6 +24,7 @@
 # available at this point.
 import os
 import urllib
+import xmlrpclib
 import cgi
 
 def application(environ, start_response):

@@ -76,21 +77,25 @@ def application(environ, start_response)
 
     # Execute corresponding operation on the CobblerSvc object:
     func = getattr( cw, mode )
-    content = func( **form )
+    try:
+        content = func( **form )
 
-    content = unicode(content).encode('utf-8')
-    status = '200 OK'
-    
-    if content.find("# *** ERROR ***") != -1:
-        status = '500 SERVER ERROR'
-        print("possible cheetah template error")
+        content = unicode(content).encode('utf-8')
+        status = '200 OK'
 
-    # TODO: Not sure these strings are the right ones to look for...
-    elif content.find("# profile not found") != -1 or \
-            content.find("# system not found") != -1 or \
-            content.find("# object not found") != -1:
-        print("content not found: %s" % my_uri)
-        status = "404 NOT FOUND"
+        if content.find("# *** ERROR ***") != -1:
+            status = '500 SERVER ERROR'
+            print("possible cheetah template error")
+
+        # TODO: Not sure these strings are the right ones to look for...
+        elif content.find("# profile not found") != -1 or \
+                content.find("# system not found") != -1 or \
+                content.find("# object not found") != -1:
+            print("content not found: %s" % my_uri)
+            status = "404 NOT FOUND"
+    except xmlrpclib.Fault, (err):
+        status = '500 SERVER ERROR'
+        content = err.faultString
 
  #   req.content_type = "text/plain;charset=utf-8"
     response_headers = [('Content-type', 'text/plain;charset=utf-8'),
openSUSE Build Service is sponsored by