Commits

Jesper Nøhr committed 489b9cf

supports calling methods on attributes too, basically namespace stacking

Comments (0)

Files changed (2)

             return self.data
         return self
     
-def obj_hook(foo):
-    print "foo", foo
-    return foo
-
 class ProxyMarshaller(simplejson.JSONEncoder):        
     def default(self, obj):
         if isinstance(obj, PuckProxy):
         self.id = id_
         
     def __getattr__(self, attr):
-        return PuckShallowMethod(self.sock, "%s.%s" % (self.method, attr))
+        return PuckShallowMethod(self.sock, "%s.%s" % (self.method, attr), self.id)
         
     def __call__(self, *args, **kwargs):
         packet = JSONCall(module=self.method, id_=self.id, args=args, kwargs=kwargs)
         self.respond(reply.to_json())
         
     def lineReceived(self, line):
+        print line
         try:
             dso = simplejson.loads(line)
         except ValueError:
             return
 
         if dso.has_key('id') and dso.get('id', None) is not None:
-            cmd = getattr(self.stack[dso.get('id')], dso.get('method'))
+            stack_ptr = self.stack.get(dso.get('id'))
+            namespaces = dso.get('method').split(".")
+            
+            for ns in namespaces:
+                stack_ptr = getattr(stack_ptr, ns)
+            
+            cmd = stack_ptr
         else:
             cmd = self.find_command(dso.get('method'))
         
         args = decode(dso.get('args'))
         kwargs = decode(dso.get('kwargs'))
-        
+                
         if cmd is not None:
             ret = cmd(*args, **kwargs)
             id_ = id(ret)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.