I have been really stuck on this and I cannot figure out how to make
my little middleware that sets the user to guest (which already exists
in database by default in my web app) when you are not logged in.
Before you say it, I want to do this so I can have fine grained
permissions.

To clarify my problem:
"environ" does not contain repoze.who.userid or repoze.who.identity
from within __call__ even when I am logged in.
I admit I am running this on TurboGears 2.1 but I wouldn't be
surprised if 2.0 has the same behaviour.

Here is my middleware:
class DefaultUser(object):
    def __init__(self, app):
        self.app = app

    def __call__(self, environ, start_response):
        if not environ.get('repoze.who.userid'):
            environ['repoze.who.userid'] = "guest"

        return self.app(environ, start_response)

Here is what I use to make an instance of the middleware in
middleware.py:
    app = make_base_app(global_conf, full_stack=True, **app_conf)

    # Wrap your base TurboGears 2 application with custom middleware
here
    app = DefaultUser(app)
    return app

I have tried many ways of trying to make this guest system work
including making an IAuthenticator plugin for repoze but nothing seems
to work for me and it is preventing me from finishing my open source
web app.

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en.

Reply via email to