Maybe I'm slow today but I don't see how to use this to break up all
controllers into seperate files.
Can I just create multiple classes in separate files that //all
subclass RootController// and then append to __init__.py //more
imports//? *What* imports?
perhaps add something like this to __init__.py ??
from myproject.controllers.anotherfile1 import
AnotherRootControllerSubClass1
from myproject.controllers.anotherfile2 import
AnotherRootControllerSubClass2
from myproject.controllers.anotherfile3 import
AnotherRootControllerSubClass3
...etc. ??
Thanks
Chris
> I did ''tg-admin quickstart -t tgbig myproject'' and noticed it now has
> a controllers directory and root.py file.
>
> Maybe I'm slow today but I don't see how to use this to break up all
> controllers into seperate files.
>
> Can I just create multiple classes in separate files that //all
> subclass RootController// and then append to __init__.py //more
> imports//? *What* imports?
This is just Python code. All modularization rules apply. You can code as
you code Python without any problems.
--
Jorge Godoy <jgo...@gmail.com>
No, you have only one RootController, the other controllers should subclass
turbogears.controllers.Controller
> and then append to __init__.py //more
> imports//?
Yep.
> perhaps add something like this to __init__.py ??
>
> from myproject.controllers.anotherfile1 import
> AnotherRootControllerSubClass1
> from myproject.controllers.anotherfile2 import
> AnotherRootControllerSubClass2
> from myproject.controllers.anotherfile3 import
> AnotherRootControllerSubClass3
from myproject.controllers.anotherfile1 import AnotherControllerSubClass1
from myproject.controllers.anotherfile2 import AnotherControllerSubClass2
from myproject.controllers.anotherfile3 import AnotherControllerSubClass3
class MyRoot(controllers.RootController):
foo = AnotherControllerSubClass1()
bar = AnotherControllerSubClass2()
blah = AnotherControllerSubClass3()
Chris
refactoring my controller modules I've noticed that it's a bit
confusing that you don't instantiate the RootController but you need to
explicitly create instances of all the other Controller classes.
The RootController is instantiated in start-yourapp.py which is,
technically, part of your app too ;)
Alberto