Skip to content

Instantly share code, notes, and snippets.

@macalinao
Created December 17, 2011 22:32
Show Gist options
  • Save macalinao/1491621 to your computer and use it in GitHub Desktop.
Save macalinao/1491621 to your computer and use it in GitHub Desktop.
error!
from pyramid.config import Configurator
from pyramid.authentication import AuthTktAuthenticationPolicy
from pyramid.authorization import ACLAuthorizationPolicy
from apogee.security import groupfinder
from sqlalchemy import engine_from_config
from .models import DBSession
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
"""
Authentication/Authorization
"""
authn_policy = AuthTktAuthenticationPolicy(
'sosecret', callback=groupfinder)
authz_policy = ACLAuthorizationPolicy()
"""
Config
"""
config = Configurator(settings=settings,
root_factory='apogee.models.RootFactory',
authentication_policy=authn_policy,
authorization_policy=authz_policy)
"""
Routes
"""
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('view_wiki', '/')
config.add_route('login', '/login')
config.add_route('logout', '/logout')
config.add_route('view_page', '/{pagename}')
config.add_route('add_page', '/add_page/{pagename}')
config.add_route('edit_page', '/{pagename}/edit_page')
config.scan()
return config.make_wsgi_app()
Traceback (most recent call last):
File "c:\env\memeplace\pyramid_debugtoolbar-0.9.7-py2.7.egg\pyramid_debugtoolbar\panels\performance.py", line 69, in noresource_timer_handler
result = handler(request)
File "C:\env\lib\site-packages\pyramid-1.3a2-py2.7.egg\pyramid\tweens.py", line 20, in excview_tween
response = handler(request)
File "C:\env\lib\site-packages\pyramid_tm-0.3-py2.7.egg\pyramid_tm\__init__.py", line 61, in tm_tween
response = handler(request)
File "C:\env\lib\site-packages\pyramid-1.3a2-py2.7.egg\pyramid\router.py", line 164, in handle_request
response = view_callable(context, request)
File "C:\env\lib\site-packages\pyramid-1.3a2-py2.7.egg\pyramid\config\views.py", line 316, in rendered_view
result = view(context, request)
File "C:\env\lib\site-packages\pyramid-1.3a2-py2.7.egg\pyramid\config\views.py", line 426, in _requestonly_view
response = view(request)
File "c:\env\apogee\apogee\views.py", line 108, in login
if USERS.get(login) == password:
NameError: global name 'USERS' is not defined
USERS = {'editor':'editor',
'viewer':'viewer'}
GROUPS = {'editor':['group:editors']}
def groupfinder(userid, request):
if userid in USERS:
return GROUPS.get(userid, [])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment