Pyramid Auth error with Persona / Browserid

123 Views Asked by At

I want to make pyramid auth in my app with persona or browser id, the problem is that using both of us i see an error.

The console drops me this when i use persona:

          Import error: No module named pyramid_persona

and when I use browser ID drops me no modul named browserid

This is my code:

MY VIEW FILE

        from pyramid.config import Configurator
        from pyramid.response import Response
        from pyramid.security import authenticated_userid

        #from waitress import serve
        from pyramid.config import Configurator
        from pyramid.response import Response
        from pyramid.security import authenticated_userid
        from pyramid.exceptions import Forbidden

def hello_world(request):
    userid = authenticated_userid(request)
    if userid is None:
        raise Forbidden()
    return Response('Hello %s!' % (userid,))

MY INIT FILE

from pyramid.config import Configurator
from resources import Root
import views
import pyramid_jinja2
import os
here = os.path.dirname(os.path.abspath(__file__))
settings={
    'persona.secret': 'some secret',
'persona.audiences': 'http://localhost:8080'
}
settings['mako.directories'] = os.path.join(here, 'templates')
__here__ = os.path.dirname(os.path.abspath(__file__))


def make_app():
    """ This function returns a Pyramid WSGI application.
    """
    settings = {}
    settings['mako.directories'] = os.path.join(__here__, 'templates')
    config = Configurator(root_factory=Root, settings=settings)
    config.include('pyramid_persona')////////////////////////THE ERROR AND TROUBLEMAKER
    config.add_renderer('.jinja2', pyramid_jinja2.Jinja2Renderer)
    config.add_view(views.my_view,
                    context=Root,
                    renderer='zodiac1.mako')
    #config.add_route( "home", "/home")
    #config.add_view(views.home_view, route_name="home", renderer="zodiac1.mako" )
    config.add_static_view(name='static',
                           path=os.path.join(__here__, 'static'))
   #    config.add_route('zodiac', '/zodiac')
    #    config.add_view(views.home_view, route_name='zodiac', #renderer='main.mako')
    #config.add_route('zodiac1', '/zodiac1')
    #config.add_view(views.home_view, route_name='zodiac1', renderer='zodiac1.mako')
    config.add_route('zodiac2', '/zodiac2')
    config.add_view(views.zodiac2_view, route_name='zodiac2', renderer='zodiac2.mako')
    config.add_route('zodiac3', '/zodiac3')
    config.add_view(views.guestbook, route_name='zodiac3', renderer='zodiac3.mako')
    config.add_route('hello', '/hello')
    config.add_view(views.guestbook, route_name='zodiac3', renderer='zodiac3.mako')

    return config.make_wsgi_app()

    application = make_app()

Please tell me what I am doing wrong, I'm sure that it didn't like how to I import config.include('pyramid_persona')

Thanks

1

There are 1 best solutions below

2
On

From this error:

Import error: No module named pyramid_persona

You can tell Python cannot find the pyramid_persona module. Perhaps because its not installed. You should install it with pip install pyramid_persona.

You will also need to install pyramid_whoauth to get BrowserID support.

This can get a bit complicated stitching all the parts together, so I recommend having a read of this great writeup by Ryan Kelly (who works at Mozilla) that shows how everything plugs together.