views:

19

answers:

1

I'm using pylons, and want to use clever css.

I created a controller SassController to handle .sass requests, but in the config/routing.py, I don't know how to write the mapping.

What I want is:

  1. client request: http://localhost:5000/stylesheets/questions/index.sass
  2. all such requests will be handled by SassController#index

I tried:

map.connect('/{path:.*}.sass', controller='sass', action='index')

But found only: http://localhost:5000/xxx.sass will be handled, but http://localhost:5000/xxx/yyy.sass won't.

What should I do now?

A: 

The routing code using regular expressions so you can make it eat everything in the url regardless of slashes.

The docs are here

It'll look something like:

map.connect(R'/{path:.*?}.sass', controller='SassController', action='index') 

#in the SassController
def index(self, path):
    return path

http://localhost:5000/blah/blah/something.sass will call SassController.index with path = blah/blah/something

Ben
Have you tried this? I remember(but not sure) I have done the same thing, but if the sass files in "public/stylesheets" directory, and you request "/stylesheets/xxx.sass", this route won't be used, I still get the raw sass content. I have to move the sass files to another directory and it works.
Freewind
Yep, I tried this using the example I posted. I tried it with Pylons 1.0.
Ben