@@ -90,7 +90,24 @@ class CollectionHandler(webapp.RequestHandler):
9090
9191 def get (self , service_name , version , collection ):
9292 service = build (service_name , version )
93- page = "<p><a href='/'>Home</a></p><pre>%s</pre>" % pydoc .plain (render_doc (getattr (service , collection )()))
93+ # descend the object path
94+ path = collection .split ("/" )
95+ if path :
96+ for method in path [:- 1 ]:
97+ service = getattr (service , method )()
98+ method = getattr (service , path [- 1 ])
99+ obj = method ()
100+ page = "<p><a href='/'>Home</a></p><pre>%s</pre>" % pydoc .plain (render_doc (obj ))
101+
102+ if hasattr (method , '__is_resource__' ):
103+ collections = []
104+ for name in dir (obj ):
105+ if not "_" in name and callable (getattr (obj , name )) and hasattr (getattr (obj , name ), '__is_resource__' ):
106+ collections .append (name )
107+
108+ for name in collections :
109+ page = re .sub ('(%s) =' % name , r'<a href="/%s/%s/%s">\1</a> =' % (service_name , version , collection + "/" + name ), page )
110+
94111 self .response .out .write (page )
95112
96113
@@ -99,7 +116,7 @@ def main():
99116 [
100117 (r'/' , MainHandler ),
101118 (r'/(\w*)/(\w*)' , ServiceHandler ),
102- (r'/(\w*)/(\w*)/(\w *)' , CollectionHandler ),
119+ (r'/(\w*)/(\w*)/(. *)' , CollectionHandler ),
103120 ],
104121 debug = True )
105122 util .run_wsgi_app (application )
0 commit comments