[EMAIL PROTECTED] wrote:
> Hi guys!
>
> I have a suggestion about the controllers, suppose the following code:
>
> . class Root(controllers.RootController):
> .     @expose(template="cheetah:myproject.templates.index")
> .     def index(self):
> .         return {}
>
> Why don't presume where the template is located? As the method name is
> index and the templates directory is myproject/templates, the expose
> method could automatically define the template path. What do you think?
>
> Thanks for attention!

That is possible, although it gets pretty tricky in anything but the
simple cases. Part of the problem is that your decorator is acting on a
function before it is bound to the class, so you can't really look up
what the function belongs to. At least that is what I think I ran into.
The real problem is that, say you have a heirarchy like this:

Root.test.manage.index

Where Root is your root controller, test and manage are controllers
attached to it, and index is the function you are exposing. A
reasonable template path would look like this:

<project>.templates.test.manage.index

However, you can't compute this path because the function is not bound
to the class when the decorator sees it, so you are stuck with a flat
heirarchy when it really is not the ideal solution.

Anyways, this should do it for you if you are still interested. I
didn't have much time to test it, just to confirm that it provides the
expected behavior. If it breaks any of the other features of expose I
would not be suprised.

http://paste.turbogears.org/paste/697

-Adam


--~--~---------~--~----~------------~-------~--~----~
 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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to