> I see that you have already gotten much advice, let me share my setup
 > which is slightly different. I have been using it to develop a
 > javascript web application for handing job applications. There is only
 > one controllers.py which contain:

Well, I've worked in large teams where bunching several classes into a 
single source file like that would result in a mob lynching.  However 
they were C++/Java dev environments and I've been assured that this sort 
of thing is a little more relaxed in Python land.

If your app was to grow and you start adding a few dozen more 
controllers with a lot more functionality per controller then I'd guess 
you'd get a better idea of why separating your controllers might be a 
good idea.  You'd find it much easier to locate objects/methods and it 
gives you the option of easily extracting controllers for use in other 
projects (perhaps a login/admin controller you might find useful 
elsewhere).  Also, having them separate discourages you from making 
controllers unnecessarily dependant on methods/code in other controllers 
which might seem acceptable if they live in the same source file.

Chances are that you'll get a good idea when your project is becoming 
uncomfortable to handle.  Again, my experience is in enivronments where 
these patterns are well recognised and working practices are put into 
place early on to avoid expensive refactorings later.  As usual, YMMV.


> On 3/14/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> 
>>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?
> 
> 
> I see that you have already gotten much advice, let me share my setup
> which is slightly different. I have been using it to develop a
> javascript web application for handing job applications. There is only
> one controllers.py which contain:
> 
> RootController
> PersonController
> DocumentController
> CompanyController
> ContractController
> 
> I dont know if there is a right way to divide your functionality into
> controllers. In my case, each controller (except for the
> RootController) maps to a database table. The controllers are used by
> the javascript frontend to send and receive JSON:ified XmlHttpRequests
> and they basically only acts as a thin layer doing validation and
> smoothing out the ugly realities of the database so that the
> javascript doesn't see it. The javascript application is written using
> qooxdoo which is a totally kickass web gui toolkit.
> 
> 
>>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...
> 
> 
> As I said, I don't know the right way to create controllers. But an
> "add_entry_controller" doesn't make any sense to me. IMHO controllers
> are classes and as such they should be subjects and represent some
> kind of object. "add entry" is more of a verb and sounds like a name I
> would give a method instead.
> 
> --
> mvh Björn
> 
> 
> 
> 


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to