Using a custom path for the controllers

1 view
Skip to first unread message

Gustavo Narea

unread,
Aug 7, 2008, 7:33:05 PM8/7/08
to TurboGears Trunk
Hello,

I'd like to have my controllers in {mypackage}.web.controllers, instead of the
default {mypackage}.controllers, but I've not found how to do so in the
documentation. Any hint?

Thanks in advance.
--
Gustavo Narea.
General Secretary. GNU/Linux Matters.
http://www.gnulinuxmatters.org/

Christopher Arndt

unread,
Aug 8, 2008, 5:26:33 AM8/8/08
to turbogea...@googlegroups.com
Gustavo Narea schrieb:

> I'd like to have my controllers in {mypackage}.web.controllers, instead of the
> default {mypackage}.controllers, but I've not found how to do so in the
> documentation. Any hint?

You are talking about TG 1? Look in the "commands.py" file. That's were
the Root controller is imported and mounted.

Chris

Alberto Valverde

unread,
Aug 8, 2008, 5:56:32 AM8/8/08
to turbogea...@googlegroups.com
Gustavo Narea wrote:
> Hello,
>
> I'd like to have my controllers in {mypackage}.web.controllers, instead of the
> default {mypackage}.controllers, but I've not found how to do so in the
> documentation. Any hint?
>

In TG2 you can subclass AppConfig for this. After reading the source
(ie: I haven't tried it) I think the way to do it is (Mark, correct me
if I'm wrong):

in yourapp/config/app_cfg.py

from tg.config import AppConfig

class MyConfig(AppConfig):
def setup_paths(self):
root = os.path.dirname(os.path.abspath(
self.package.__file__))
self.paths = dict(root=root,
controllers=os.path.join(root, 'web',
'controllers'), # <-- Note the 'web' path component
static_files=os.path.join(root, 'public'),
templates=[os.path.join(root, 'templates')

base_config = MyConfig()

Alberto


Gustavo Narea

unread,
Aug 8, 2008, 9:47:13 AM8/8/08
to TurboGears Trunk
Hi, Christopher.

Sorry, I'm talking about TG2.

Gustavo Narea

unread,
Aug 8, 2008, 12:39:26 PM8/8/08
to turbogea...@googlegroups.com
Hello, Alberto.

Thanks for your answer! Unfortunately, it won't work because of this bug:
http://trac.turbogears.org/ticket/1932

BTW, please take a look at this: http://trac.turbogears.org/ticket/1931

Cheers!

> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google Groups
> "TurboGears Trunk" group. To post to this group, send email to
> turbogea...@googlegroups.com To unsubscribe from this group, send
> email to turbogears-tru...@googlegroups.com For more options,
> visit this group at http://groups.google.com/group/turbogears-trunk?hl=en
> -~----------~----~----~----~------~----~------~--~---

signature.asc
Reply all
Reply to author
Forward
0 new messages