Yeah, turns out the StaticURLParser didn't work so well. Each of my
themes had different images but with the same name and so I would get
the wrong images in a site, even though it was named correctly. Based
on your suggestion I've switched things up to do a couple things:

1. There's a site object which has theme info. The controller has
access to this and can get the appropriate template.

2. That same object is available to each Mako template and the static
file URLs are dynamic as well, getting the appropriate file for that
theme.

This works great and I don't really mind have two locations for files.

Thanks for the tip!

Cheers,

Jon

On Nov 24, 4:21 pm, Wyatt Baldwin <[email protected]> wrote:
> On Nov 24, 3:22 pm, jon <[email protected]> wrote:
>
> > These all seem like really good ideas, for certain. What I ended up
> > doing is in my middleware.py I query my database to get all the
> > current themes and a dirname attribute. I then build and add the paths
> > for each theme along with building a StaticURLParser for each theme.
> > All of that gets passed into Cascade and I'm good to go. Works nicely.
>
> Seems like adding a StaticURLParser for every theme would be a little
> inefficient, though perhaps insignificantly so for your app. Do you
> actually have a need to have all the themes loaded all the time?
>
> I have a vague idea about using a url_for_theme helper instead, though
> this idea would work a little better (I think) if you were willing to
> put all of the static files for all themes in the same place. I.e., if
> you put all the themes under public/themes, then you could switch
> themes simply with url_for_theme(current_theme_name), perhaps storing
> current_theme_name in the session, a cookie, or the user's profile.
>
> This doesn't work with your idea of keeping everything in the same
> directory, but I wouldn't see that as too big of a deal--a theme could
> be "installed" simple by copying the static files for the theme into
> public/themes/{theme_name} and the templates to templates/
> {theme_name}.
>
> Something else that's good about this approach is that it would more
> easily (I think) allow you to switch to serving your themes' static
> files directly from Apache.
>
> Anyway, that might not work for your situation, but it seems like an
> interesting approach.

--

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