2014-02-17 46 views
0

我想在我的應用程序與人物角色或瀏覽器ID金字塔認證,問題是,使用我們兩個我看到一個錯誤。金字塔認證錯誤與角色/瀏覽器

控制檯降低我這個當我使用的人物角色:

  Import error: No module named pyramid_persona 

,當我使用的瀏覽器ID下降我沒有MODUL命名BROWSERID

這是我的代碼:

我看來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文件

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() 

請告訴我,我做錯了,我敢肯定,它不喜歡我如何導入config.include(「pyramid_persona」)

感謝

回答

0

從這個錯誤:

Import error: No module named pyramid_persona 

你可以告訴Python不能找到pyramid_persona模塊。也許是因爲它沒有安裝。您應該使用pip install pyramid_persona進行安裝。

您還需要安裝pyramid_whoauth才能獲得BrowserID支持。

這可能會讓所有零件拼接在一起變得有些複雜,所以我建議閱讀由Ryan Kelly(誰在Mozilla工作)的this great writeup,它顯示瞭如何將所有東西插在一起。

+0

嗨Burhan,坦克回答我,我已經安裝了,但現在我有很多錯誤,使我的構建,類似的錯誤:KeyError:'repoze.lru:未找到包,WTF是repoze.lru? – BugFixer

+0

你有setup.py嗎?看起來你錯過了很多軟件包。 ['repose.lru'](https://pypi.python.org/pypi/repoze.lru)是最近最少使用的緩存API。我認爲你需要確保你的設置一切正常。 –