When nesting RestControllers, the nested controllers don't dispatch requests to non-restful methods (subcontrollers are dispatched). E.g. using this set of controllers in a project "Foo":
from tg import expose, request
from tg.controllers import TGController, RestController
class MyTGController(TGController):
@expose('json')
def index(self, p, *k):
return dict(path=request.path, s=repr(self), m='index', p=p, k=k)
class MyNestedRestController(RestController):
tg = MyTGController()
@expose('json')
def get_one(self, id):
return dict(path=request.path, s=repr(self), m='get_one', id=id)
@expose('json')
def nonrestful(self, p, *k):
return dict(path=request.path, s=repr(self), m='nonrestful', p=p, k=k)
class MyRestController(RestController):
nested = MyNestedRestController()
tg = MyTGController()
@expose('json')
def get_one(self, id):
return dict(path=request.path, s=repr(self), m='get_one', id=id)
@expose('json')
def nonrestful(self, p, *k):
return dict(path=request.path, s=repr(self), m='nonrestful', p=p, k=k)
class RootController(TGController):
tg = MyTGController()
rest = MyRestController()
@expose('json')
def index(self, p, *k):
return dict(path=request.path, s=repr(self), m='index', p=p, k=k)
Results:
/ -> {"p": [], "s": "<foo.controllers.root.rootcontroller object="" at="" 0x7f122c025090="">", "path": "/", "k": {}, "m": "index"}
/rest/tg -> {"p": [], "s": "<foo.controllers.root.mytgcontroller object="" at="" 0x7f122c015850="">", "path": "/rest/tg", "k": {}, "m": "index"}
/rest/nonrestful -> {"p": [], "s": "<foo.controllers.root.myrestcontroller object="" at="" 0x7f122c015990="">", "path": "/rest/nonrestful", "k": {}, "m": "nonrestful"}
/rest/1 -> {"path": "/rest/1", "s": "<foo.controllers.root.myrestcontroller object="" at="" 0x7f122c015990="">", "m": "get_one", "id": "1"}
/rest/1/tg -> {"p": [], "s": "<foo.controllers.root.mytgcontroller object="" at="" 0x7f122c015850="">", "path": "/rest/1/tg", "k": {}, "m": "index"}
/rest/1/nonrestful -> 404</foo.controllers.root.mytgcontroller></foo.controllers.root.myrestcontroller></foo.controllers.root.myrestcontroller></foo.controllers.root.mytgcontroller></foo.controllers.root.rootcontroller>
I guess this could be related to ticket #2500.
NB: This is the TG version currently included in Fedora 14, i.e. Hg rev 1048:0fb969ca9f0f (one before 2.1rc1) with 1046:2660f1d9ac18 backed out to remove kajiji dependency.