i have been writing my web application with Pylons for some time now
and i'm, overall, quite happy with it. i managed to get mako working,
the app uses unicode/utf8 throughout, routing works, mod_python under
apache works (and reasonably fast), and so on. it was possible for me
to get most things i wanted working.

now i already have assembled sort of a codebase and i wonder whether
there is a best practice or perhaps some ideas how to get 'functional
components' or 'sub-applications' implemented. By this i mean
collections of precedural code (python module), (templated or static)
bits of html, (templated or static) css styling, images and other
resources. and client-side code (javascript) working.

the way that i'm working right now means that i always apply the MVC
paradigm at the application level. so imagine i'd write, say, an
application that provides a virtual casino for visitors, one with a
lot of roulettes and fruit machines and all that. applying the MVC
paradigm at the top means that all the controllers, css, javascript,
and imagery that i need to display and run slot machine A will be
split into the controllers directory for the code, the template
directory for the html, and the public directory for the css and the
images:

  controllers
    controller_A.py
  templates
    template_A.mako
  public
    A.css
    A.js
    A001.jpg
    A002.png

same goes for machine -- functional component -- B, C and so on (in
addition, there may be dependencies to Python libraries, but let's
just neglect that for the moment). obviously, it would be possible to
work with subdirectories /controllers/A/..., /public/A/..., but still
the parts of each machine would still be scattered across several
locations.

is there a way in Pylons to restructure this tree so it becomes more
like this:

  machines
    A
      A.css
      A.js
      A001.jpg
      A002.png
      A.py
      A.mako
    B
      B.css
      ...

of course, if you were to tell me this breaks MVC i'd say ok let's do
it this way:

  machines
    A
      public
        A.css
        A.js
        A001.jpg
        A002.png
      templates
        A.mako
      controllers
        A.py
    B
      ...

so these thingies become more like real sub-applications.

i imagine it should be possible to render several such components on a
single page and still keep the code for each together, making it
somewhat easier to maintain and to move them.

the way i work now means i have to include a partial mako template on
my page in one place and see to it i include the references to
javascript and css files in another one. i am already using mako's
ability to target specific content for specific parts of the page (by
defining e.g. 'header' in the partial template and refer to that
entity in the layout template at an appropriate point). it's still not
that modular.

i'd really love to be able to include a given machine simply as `$
{machineA(foo=42,bar=108)}`, have all the resources included into the
page, and keep those resources togther in a common subtree. maybe i
can even write out each subapplication as a separate Pylons app?

any ideas?


_wolf


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to