我想在我的应用程序中使用个人角色或浏览器id来创建金字塔,问题是使用我们两个人时,我看到了一个错误。
当我使用角色时,控制台会将我抛之脑后:
Import error: No module named pyramid_persona当我使用浏览器ID时,没有一个名为browserid的模块
这是我的密码:
我的视图文件
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,))我的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')
谢谢
发布于 2014-02-17 12:36:39
从这个错误:
Import error: No module named pyramid_persona您可以告诉Python找不到pyramid_persona模块。也许是因为它没有安装。您应该用pip install pyramid_persona安装它。
您还需要安装pyramid_whoauth才能获得BrowserID支持。
这可能会有一些复杂的拼接所有部分在一起,所以我建议阅读由瑞安凯利(他在Mozilla工作)的这篇伟大的作品,显示如何将所有的插头在一起。
https://stackoverflow.com/questions/21829104
复制相似问题