Commits

Luke Arno  committed 007ea4b

updated consumes list and finished out the docstrings on barrel component

  • Participants
  • Parent commits a957e43

Comments (0)

Files changed (2)

File docs/components/barrelsec.rst

       :show-inheritance:
       :undoc-members:
 
-      .. attribute:: consumes = ['invalidate_session', 'get_session']
+      .. attribute:: consumes = ['invalidate_session', 'get_session', 'get_locations', 'render_view', 'valid_user', 'user_roles','get_user', 'login', 'logout', 'need_auth', 'denied']
 
       .. attribute:: provides = ['valid_user', 'user_roles', 'get_user', 'login', 'logout', 'login_page', 'logout_page', 'need_auth', 'denied']
 

File haus/components/barrelsec.py

 from haus.components.abstract import Component, update_wrapper
 from haus.core import tack
 
+
 class BarrelSecurityComponent(Component):
+    """Provide security to the stack."""
 
-    consumes = ['invalidate_session', 'get_session']
+    consumes = ['invalidate_session', 'get_session', 'get_locations', 
+                'render_view', 'valid_user', 'user_roles','get_user',
+                'login', 'logout', 'need_auth', 'denied']
     provides = ['valid_user', 'user_roles', 'get_user', 
                 'login', 'logout', 'login_page', 'logout_page',
                 'need_auth', 'denied']
 
     def __init__(self, wrk):
-        """."""
+        """Some initialization delegated to the other init_* methods."""
         session_config = wrk.config.get('sessions', {})
         self.session_key = session_config.get('environ_key')
         config = wrk.config.get('barrel', {})
             wrk.pdfilename('html/_layouts/default.html')
         )
 
-
     def __call__(self, wrk, *args, **kwargs):
-        """."""
+        """Use barrel defaults from config, overridden by kwargs."""
         wrk.functions['need_auth'] = wrk.stackify(self.need_auth)
         wrk.functions['denied'] = wrk.stackify(self.access_denied)
 
         return middleware
 
     def valid_user(self, username, password):
+        """Check the validity of a username/password."""
         return username and password and \
             self.secrets.get(username) == password
 
 
     @tack(['sessions', 'yaro'])
     def login_page(self, req):
-        """."""
+        """Implements a login page."""
         username = req.form.get('username', '')
         password = req.form.get('password', '')
         funcs = req.environ['haus.functions']
 
     @tack(['sessions', 'yaro'])
     def logout_page(self, req):
+        """Implementsa logout page."""
         template_vars = dict(
             layout=self.layout
         )
 
     @tack(['sessions', 'yaro'])
     def access_denied(self, req):
+        """Implements an "access denied" page."""
         get_user = req.environ['haus.functions']['get_user']
         template_vars = dict(
             username=get_user(req.environ),