1. Eric Larson
  2. Dad

Commits

Eric Larson  committed c260dbe

Fixed the get service test

  • Participants
  • Parent commits 4741bc2
  • Branches default

Comments (0)

Files changed (1)

File dad/web/control/main.py

View file
  • Ignore whitespace
     exposed = True
 
     @cherrypy.tools.json_out()
-    def GET(self, name=None):
+    def GET(self):
         conf = cherrypy.engine.publish('dad.get_service_conf').pop()
-        names = [name]
-        if not name:
-            names = conf.keys()
         out = {}
         for name, c in conf.iteritems():
             out[name] = dict((act, '/services/%s/%s' % (name, act))
 
     def __init__(self, name):
         self.name = name
-        self.conf = self.get_conf()        
+        self.conf = self.get_conf()
 
     def get_conf(self):
         return cherrypy.engine.publish('dad.get_service_conf').pop().get(self.name)
 
     def do_action(self, action, **params):
-        cherrypy.engine.publish('dad.action.%s' % action, 
-                                self.name, self.conf, **params)
-        return 
+        result = cherrypy.engine.publish('dad.action.%s' % action, 
+                                         self.name, self.conf, **params).pop()
+        return result
 
     @cherrypy.tools.json_out()
     def POST(self, action, **params):
+        if not self.conf:
+            msg = '%s is not a valid app\n%s' % (self.name, self.conf.keys())
+            raise cherrypy.HTTPError(404, msg)
+        
         if action in self.conf.get('config', {}) or action in DEFAULT_ACTIONS:
-            result = self.do_action(action, **params)
-            return result
+            return self.do_action(action, **params)
+
         raise cherrypy.HTTPError(404, '%s is not a valid action' % action)
 
+    @cherrypy.tools.json_out()
     def GET(self):
-        print 'GET'
+        # list default actions
+        out = dict((act, '/services/%s/%s' % (self.name, act))
+                   for act in DEFAULT_ACTIONS)
 
+        # list our extra actions
+        if self.conf['config']:
+            out.update(dict((action, '/services/%s/%s' % (self.name, action))
+                            for action in c.get('config', {})))
 
+        return out
+            
+        
+        
+