Commits

Jesper Nøhr committed 2b8da7d

hub supports kwargs and proper args unpacking, moving example-fs towards a filesystem as it was meant to be

Comments (0)

Files changed (3)

 
         if self.is_raw(self.obj):
             kwd.update({ 'data': self.obj })
-        else:
+        elif hasattr(self.obj, '__dict__'):
             kwd.update({'object': self.obj.__dict__})
         
         kwd.update({'id': id(self.obj)})
             cmd = self.find_command(dso['method'])
         
         if cmd is not None:
-            ret = cmd(dso['args'])
+            ret = cmd(*dso.get('args'), **dso.get('kwargs'))
             id_ = id(ret)
             self.stack[id_] = ret
             reply = JSONMarshaller(ret)

tests/example-fs/client.py

 
 if __name__ == "__main__":
     c = PuckClient('localhost', 8080)
-    print c.repository('foo')
-    
+    print "Now use 'c'."

tests/example-fs/ehub.py

 from puck.hub import Hub, HubFactory
 
-class fakerepo(object):
-    def __init__(self):
-        self.candy = 42
-        self.string = "sixteen"
-        
-    def changectx(self, *args):
-        return { 'changectx': 'reply' }
-
 class EFSHub(Hub):
-    def remote_repository(self, *args):
-        return fakerepo()
+    def remote_file(self, fname):
+        return file(fname, 'w')
 
 class EFSHubFactory(HubFactory):
     protocol = EFSHub