On 12/19/06, Ian Bicking <[EMAIL PROTECTED]> wrote:
> I have created a Pylons project (with paster create --template=pylons
> qw) and I am a bit intimidated with amount of data pre-generated for
> me: 33 files with 573 lines in them (16Kb)! Similar situation in
> TurboGears, btw.
I've always thought of Pylons as a "more modular and less ambitious"
equivalent to TurboGears, so it's not surprising the project files are
a similar size. I like the fact that TG and Pylons start with a
fully-configured application, and enabling optional features is just a
matter of following the comments. I can see the point for a minimal
project template too, so it's good that both the minimum and
full-featured are available rather than trying to please everybody
with one.
config.environment:
Mostly setting up some Myghty paths. This doesn't seem very
interesting or worth editing.
controllers.error & template:
template is basically just a docstring. The error handler seems
reasonable.
Could these be moved into Pylons itself? Or have a default
implementation in Pylons and an empty module (or part of a module, or
even just instructions on the wiki to create a module) if the user
needs to override it.
lib.globals:
Mostly a docstring
I have a feeling this will be useful for something.
lib.base:
A bunch of imports; all the stuff you use in your controllers. I
don't think this can be usefully trimmed without moving all the imports
into individual controllers.
This is vital. It's the one case I've seen where "from ... import *"
is justified. The base controller is a good place to set self
variables for all controllers, and I've also found it useful to put
multiple base controller subclasses in that module.
config.middleware:
This one is quite large. It has two config objects (a bit
confusing), and then it sets up some of the mini-apps (e.g.,
static_apps) and middleware.
Some of the middleware doesn't need to be there. E.g., PylonsApp
could apply ConfigMiddleware by default. Probably httpexceptions could
be in place by default too, since it always should be tightly bound to
the app anyway.
At minimum I'd suggest some more specific comments about what each
middleware does and why it's there, and explain what's happening with
those mysterious '*conf" thingies.
Maximally, I'd recommend the following. (I don't have a middleware.py
in front of me so I'm going my my analysis and memory.) Make a clear
distinction between:
1) Mandatory components. Things that would break Pylons if they were
omitted, or would make users think "What the *&^# is going on?" E.g.,
config, registry, 'g' global. These should be moved out of make_app()
as much as possible.
2) Standard Pylons components we think are good for everybody. Things
nobody would override unless they're doing something very unusual. I
think the error handling, static files, and Javescript files belong in
this category. These middlewares can maybe be moved out of
make_app(), and optional config vars added to disable them one by one
(if we think that's necessary). Of course, the config vars should not
be mentioned in the default config file; that would clutter it and
confuse newbies.
3) User-defined middleware. This is what make_app() is for.
We can do this by restructuring make_app() like this:
def make_app(global_conf, **app_conf):
app = init_app(global_conf, app_conf)
# Does load_environment, config.init_app, PylonsApp, 'g',
ConfigMiddleware...
# Maybe needs 'helpers', 'g', and 'package' arguments.
# User-defined middleware goes here.
return finish_init_app(app)
# Does error handling, cascade, registry...
This means make_app() has only two little mandatory lines at the top
and bottom. Out of the way, easy to see they do "something magic",
and more difficult for the user to screw up.
--
Mike Orr <[EMAIL PROTECTED]>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---