"Ian Wilson" <[EMAIL PROTECTED]> writes:
> How do you organize the forms iain ? I mean I have probably 30+ forms with
> 10+ controller classes. You just put all the forms in one file ? Don't the
> names clash ? Or do you have some sort of alternate organization?
I have a project with hundreds of forms and dozens of controllers.
Each controller is in a module by itself (made up names):
- finances
- taxes
- ...
- human_resources
- employees
- absences_from_work
- medical_exams
...
- ...
Inside each module I have a 'forms.py'. So, I do in my main controller:
================================================================================
from project.controllers.finances import Finances
from project.controllers.human_resources import HR
from ... import ...
...
class Root(RootController):
finances = Finance()
hr = HR()
@expose('template_with_index_for_resources')
def index(self, ...):
...
================================================================================
And then, inside each module I have:
(example for the human resources module)
================================================================================
from employees import Employees
from absences import Absences
from ... import ...
class HR(Controller):
employees = Employees()
...
@expose('template_with_index_for_resources')
def index(self, ...):
...
================================================================================
And in employees, for example:
================================================================================
from forms import form_for_new_employee
from forms import grid_for_employees
from forms import ...
class Employees(Controller):
@expose('template...')
def index(self, ...):
show_grid
@expose(...)
def add(...):
...
@expose(...)
def edit(...):
...
================================================================================
So I have my 'modules' self-contained within their namespaces. If I need for
example to select some specific employee I create a SingleSelect *inside the
human resources module* forms.py and import it from there where I need the
selection to be made:
================================================================================
from project.controllers.human_resources.forms import select_employee
================================================================================
This allows me having a modular approach where I can add / remove
funcionalities on the system by adding controllers.
I could have adopted the same approach with my ORM models, but I didn't want
to have the headache of including several models by the time that SO had a few
bugs with import order for external files. Today I believe this has been
fixed and it would be a nice thing to do (who knows if I will migrate that in
the future...).
The idea is then having each module as a WSGI module or a separate egg and by
adding those to the system -- they would be found automatically through entry
points -- the system would "grow" and adapt itself to the new funcionalities.
This architecture comes from more than a year of project, so a lot of things
that existed by the time were fixed / enhanced today and you could make it
better for your project.
This is for a big system that is modular and has custom modules for each
customer I have.
(Oh, and by the way, it also has a barcode printing module that sends data to
an Argox OS214TT printer ;-), is integrated with barcode readers on each
terminal, etc. all through the web with TG powering it :-))
--
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?hl=en
-~----------~----~----~----~------~----~------~--~---