Hi,
I am trying to incorporate "rum" into my pylons project. This was the
first time I have tried to incorporate another wsgi app into an
existing pylons app.
The rum docs state that a way to do this is to create a controller as
a *function*, like so:
def AdminController(environ, start_response):
authorize('admin') # calls redirect_to('login') if not logged in
...
return my_rum_app(environ, start_response)
routes are something like:
map.connect('admin', '/admin', controller='admin')
map.connect('/admin/{url:.*}', controller='admin')
So all /admin.* urls go to this function, AdminController. And it
works fine.
However, when I want to to some authentication, and call redirect_to
("login") before the final call to my_rum_app if not logged in, I
don't get a redirect, but rather an uncaught exception:
"HTTPFound: 302 Found content-
type: text/html; charset=UTF-8 Content-Length: 0 location: /login/ "
I figured out a way to avoid this problem, but am wondering if there
is a better way. Here is what I did:
Instead of controller function, I made a standard controller class,
with a single action "index". It turns out that for the routes above,
*all* requests go to index() (not sure why!).
class AdminController(BaseController):
def index(self):
authorize('admin')
...
return my_rum_app(request.environ, self.start_response)
This works just fine and redirects work correctly, but am wondering
how to fix up the first solution with controller as a function so that
the redirect exceptions are processed by pylons. Partially, the reason
I would like to know is to increase my understanding of how this whole
thing works!
Thanks,
David
PS: "rum", by the way, looks like a dynamite package! Haven't played
with it enough to know everything, but looks like it could easily
function as the admin CRUD interface everybody thinks is so great
about rails...
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---