I am in the process of writing an app that will have a "theme" based
on if a subdirectory is specified e.g.:

http://somesite.com/app/(theme)/abunchofviews/

basically, if they go to /app/bluetheme/register, it'll give them a
registration page with a blue theme header and footer  (it looks up a
theme object based on the value specifed in the url, and gets header
images, etc from said object). Likewise, if "greentheme" is specified,
they would get a green-themed registration page. This way, someone can
later just go into the django admin section and create a new "theme"
by specifying a new header and footer image.

If the theme specified doesn't exist, I'd like to redirect them to a
url patten without the theme in the name, e.g. just /app/
abunchofviews/, which will show a default theme.

Right now, there are about 3-4 views after where the theme is
specified in the url, and it seems like it's going to get a bit
repetitive doing the lookup (and redirecting if it doesn't exist) in
every view. I could break this out into a function call that is called
from every view function, but I was curious as to what everyone
thought about if this would be a candidate for being written as
middleware? Right now it looks like I only need it for this particular
app, and not any other ones on the site, if that makes a difference.

I am a little new to writing middleware, so please tell me if you
think there is a better way to do this, or if just calling it in every
view is appropriate.

Thanks in advance!

-Chris


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to