You should be able to extend the base controller and add a help
function to that. I just tested it using a mixin which seems to work
pretty well. Here is what I did:
class Helper:
@turbogears.expose()
def help(self):
return dict(path=cherrypy.request.path)
class Root(controllers.RootController, Helper):
...
At that point root automatically gets a help method, and to add it to
anything other objects you would just mixin that same class. I had some
success adding it as an attribute of a method too, but I am not too
sure if that is a good way to handle it. Anyways, here is what I did
for that:
class Root(controllers.RootController, Helper):
...
@turbogears.expose()
def test(self)
return dict(test="This is a test.")
test.help = Helper().help
With testing it seems like this works well, even with the test function
accepting parameters. My guess is that calls to test/help are processed
by any attributes of test before they are turned into parameters of the
test method call.
Anyways, hope that helps. It does not entirely avoid having to make
calls to context_sensitive_help(), but it does limit the whole thing to
mixins and assigning attributes to methods. I have absolutely zero
experience with cherrypy filters, so I may be reinventing the wheel
there ... guess I have reading to do.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---