On May 22, 2010, at 2:41 PM, Wyatt Baldwin wrote:
> I think at the very least a documented method for "blending" Pylons
> apps would be useful. If I have an app and I want to add this or that
> functionality from some other Pylons app, what's the best way to do
> that? How do I pull in the static files and the templates?
>
> In my case, at work, I'm creating a base app from which other apps
> extend. There's a bunch of common stuff that I don't want to repeat
> per app: base config from INI file, environment setup, shared static
> files, shared templates, common error handling, etc.
>
> I've got this pretty much worked out, and I'm feeling pretty good
> about it, but I wonder if there's a "best practice" for doing this
> sort of thing? It's possible that everyone will need to do custom
> setup anyway, but maybe some recipe type documentation would be handy.
> I'd be happy to share my base package if anyone's interested.
Right now, its kind of messy. It's totally possible, but it involves importing
bits from here and there in your main app, etc. For example, you could make a
package that had some models in it, then just import them in your
models/__init__.py, and call the init_model for the other package with your
configured engine.
And you could add in additional template paths, by using Mako's multiple
template search paths, but yea, no best practices or examples of this. It's
also not trivial to get the location of mako templates that are inside another
package installed somewhere on the system.
Pylons does support dotted notation now for controllers, so you can hook up a
controller like so:
map.connect('/home', controller='homepackage.controllers.home:HomeController',
action='index')
One of the first things I want to add for Pylons 1.1, is better capabilities
for extension points. While sub-classing seems ok for extending things, it
quickly becomes a nightmare in larger apps. So I was planning on utilizing
Marco so that we'd have an event system, and a registry where plugins could be
registered, and handlers for the plugins could indicate they want to be
triggered on an event.
Most of the common things Pylons does when loading an app will trigger events,
which should provide lots of extension points.
Cheers,
Ben
--
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.