Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Changes between Initial Version and Version 1 of LageApplication

04/22/06 17:12:11 (13 years ago)



  • LageApplication

    v1 v1  
     1TG 0.9a4 
     3= Designing for a 'Large' Application = 
     5The default TG setup is a little more Pythonic than some web developers are used to, and doesn't lend well to a collaborative development environment that uses SVN for different permissions based on directory structure. 
     7Most of this can be quickly alleviated with some design ideas. 
     9== The Controllers == 
     11There are 2 ways to split controllers up in TurboGears 
     13=== The TG way === 
     14Introduced in TG 0.9a2 , the tgbig template adds a controllers package to the template. 
     15controllers.py is replaced with a controllers directory 
     16 {{{ 
     17        tg-admin quickstart -t tgbig  
     18 }}} 
     20=== The Other ways === 
     21Some people prefer these.  Several on the Newsgroup seemed to have implemented variations on this 
     23==== The FastTrack way ==== 
     24In FastTrack, a 'subcontrollers' directory was created 
     25controllers.py reads as follows (abridged): 
     26 {{{ 
     27from subcontrollers.dashboard       import DashboardController           
     28class Root(controllers.RootController):          
     29    dashboard       = DashboardController() 
     30 }}}     
     31subcontrollers/dashboard.py reads: 
     32 {{{ 
     33from fasttrack.model        import Person, Project, status_codes 
     34class DashboardController(identity.SecureResource): 
     35    require = identity.not_anonymous() 
     38Note that model needs to be specifically addressed in regards to namespace 
     40==== Another way ==== 
     41This was posted to the Newsgroup by justi...@ntlworld.com 
     43I renamed controllers.py to controller.py - the idea being that this is just the _root_ controller.  
     44Next, I created a directory: controllers/  
     45which contains things like:  
     47    blog_controller.py  
     48    forum_controller.py  
     49    login_controller.py  
     50    json_api_controller.py  
     51    ...  
     52For controller.py then:  
     53from controllers.blog_controller import BlogController  
     54from controllers.forum_controller import ForumController  
     55from controllers.login_controller import LoginController  
     56from controllers.json_api_controller import JsonApiController  
     57class Root(controllers.RootController):  
     58    blog = BlogController()  
     59    forum = ForumController()  
     60    login = LoginController()  
     61    json_api = JsonApiController()  
     64=== Related Newsgroup Postings: === 
     65 * [http://groups.google.com/group/turbogears/browse_thread/thread/e7fe18aadf6979da/2894f193485fde01?q=tg-big&rnum=3#2894f193485fde01 TurboGears 0.9a2 released!] 
     66 * [http://groups.google.com/group/turbogears/browse_thread/thread/776d000e0e8e3acc/56daa2795b20103c?q=tg-big&rnum=2#56daa2795b20103c bike shed #2: controllers.py vs. controllers] 
     68== The Templates == 
     70The way to get templates into subdirectories seems to change based on TG revisions - I tried some tricks from the newsgroup ( Some people said import each template directly, others created controllers to juggle namspace issues ) but none worked on .09a4.   
     72What does work on 0.9a4 , is this: 
     74 *  For any subdirectory in templates, 'touch __init__.py' - TG/Kid/Cherrypy needs it (all versions) 
     75 *  For any template that inherits , use relative urls to the inherited document -- ie: py:extends="'master.kid'" should be py:extends="'../master.kid'"