Elliot Peele avatar Elliot Peele committed 27ceef8 Draft

add more stuff, still working

Comments (0)

Files changed (2)

authztest/__init__.py

 import epdb
 sys.excepthook = epdb.excepthook()
 
+from pyramid.decorator import reify
+from pyramid.request import Request
 from pyramid.security import Allow
 from pyramid.security import Everyone
 from pyramid.security import Authenticated
             self.__dict__.update(request.matchdict)
 
 
+class RequestFactory(Request):
+    @reify
+    def user(self):
+        user = None
+        return user
+
+
 def main(global_config, **settings):
     """ This function returns a Pyramid WSGI application.
     """
     config = Configurator(settings=settings)
     config.add_route('base', '/base')
+    config.add_route('base_api_auth', '/base/apiauth')
     config.add_route('test', '/')
 
     config.add_route('login', '/login')
     config.set_session_factory(UnencryptedCookieSessionFactoryConfig(secret))
 
     config.set_root_factory(RootFactory)
+    config.set_request_factory(RequestFactory)
 
     config.scan()
     return config.make_wsgi_app()

authztest/views.py

         return self._call_method('_delete')
 
 
-@view_defaults(renderer='json', route_name='test', permission='authenticated')
-class Test(BaseView):
+@view_defaults(renderer='json', route_name='base_api_auth', permission='authenticated')
+class APIAuthView(BaseView):
+    pass
+
+@view_defaults(route_name='test')
+class Test(APIAuthView):
     def _get(self):
         return {'data': 'get'}
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.