Can you post the error which causes the issues? I don't think why
SessionMiddleware has to have requires_auth attribute.

requires_auth is defined in the base controller. May be you need to
access requires_auth as self.requires_auth, its not
session.requires_auth.

You can use AuthKit or Repoze.What frameworks for authentication and
authorization. I believe authkit is improving much but repoze.what
rocks...

Did you follow 
http://wiki.pylonshq.com/display/pylonscookbook/Simple+Homegrown+Authentication
? May be, you could have missed something..



On Apr 10, 2:59 pm, Richard Jones <[email protected]> wrote:
> Hi Folks,
>
> Sorry if this is a newbie question, but I'm having trouble figuring
> out session management in pylons using the built in beaker module.
>
> I am attempting to do session management and authentication using the
> following:
>
> class BaseController(WSGIController):
>
>     requires_auth = False
>
>     def __before__(self):
>
>         # set up the session management
>         self = SessionMiddleware(self, key="mykey",
> secret="randomsecret")
>
>         # Authentication required?
>         if self.requires_auth and 'user' not in self.session:
>             # Remember where we came from so that the user can be sent
> there
>             # after a successful login
>             self.session['path_before_login'] = request.path_info
>             self.session.save()
>             return redirect_to(h.url_for(controller='login'))
>
> on execution of a controller which subclasses BaseController, I get an
> error which says that SessionMiddleware does not contain an attribute
> "requires_auth".
>
> I'm a pretty much complete python beginner, so I might just be missing
> something with regard to how the __before__ method actually functions,
> but this code is partially copied from an example I found on pylonshq
> as to how to hack together quick and dirty authentication for
> individual controllers.  In addition, I have completely guessed as to
> how to use the SessionMiddleware object, and if anyone can point me to
> more complete beaker documentation than that which is available on
> their wiki, that would be an enormous help.
>
> Thanks very much,
>
> Richard
--~--~---------~--~----~------------~-------~--~----~
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