"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > I would like to see various examples of how multiple controller files > are used in the real world within TG. This thread has grown so large > and no one has shared any concrete examples yet. :) Anyone? Anyone?
OK... What I have here is: https://my.site.com/ main -> controller big_functionality_1 -> controller /add -> method /update -> method /delete -> method / -> method big_functionality_2 -> controller /add -> method /update -> method /delete -> method / -> method big_functionality_3 -> controller /add -> method /update -> method /delete -> method / -> method big_functionality_4 -> controller /add -> method /update -> method /delete -> method / -> method And in my Python code: (controllers.py) (... standard imports ...) (... Python modules imports ...) # My Project's imports from project.big_func1 import Big1 from project.big_func2 import Big2 from project.big_func3 import Big3 from project.big_func4 import Big4 class Root(controllers.RootController): big_functionality_1 = Big1() big_functionality_2 = Big2() big_functionality_3 = Big3() big_functionality_4 = Big4() (... rest of standard file with small changes ...) Then it is just a matter of having each BigN to answer for its URL. In it there should be at least default() and index() methods @expose()d. > I have a controllers.py that must be 1000 lines now, and it is just > getting a bit long. I need to cut it up, but am not sure of the best > way. I know I need to create some "helper classes" to separate out > certain functionality that is not related to url-mapping, but as far as > having controllers.py as: > controllers/ > __init__.py > detail_controller.py > add_entry_controller.py > etc... > > Any pointers/examples would be great. I hope I helped. If you want to have what was proposed here of a controllers module inside your project, then you'd have all these imports inside project/controllers/__init__.py instead of project/controllers.py ... And you'd have to remember to import everything from project.controllers.big_funcN. This way, all that is related to http://my.site.com/big_functionality_1 is at the file project.big_func1. The same for other parts of the site. For common code you can import from project.utilities or project.utils or something like that. If you're not using the "controllers" module, then you can use relative imports and "import utils"... Be seeing you, -- Jorge Godoy <[EMAIL PROTECTED]> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

