[xiph-commits] r4039 - in arkaiv/trunk: . arkaiv/controllers

dcrowdy at svn.annodex.net dcrowdy at svn.annodex.net
Mon Sep 28 17:49:59 PDT 2009


Author: dcrowdy
Date: 2009-09-28 17:49:59 -0700 (Mon, 28 Sep 2009)
New Revision: 4039

Modified:
   arkaiv/trunk/arkaiv/controllers/collection.py
   arkaiv/trunk/arkaiv/controllers/list.py
   arkaiv/trunk/development.ini
Log:
Basic public/private/admin role-based authentication implemented through collections


Modified: arkaiv/trunk/arkaiv/controllers/collection.py
===================================================================
--- arkaiv/trunk/arkaiv/controllers/collection.py	2009-09-28 05:57:38 UTC (rev 4038)
+++ arkaiv/trunk/arkaiv/controllers/collection.py	2009-09-29 00:49:59 UTC (rev 4039)
@@ -25,7 +25,7 @@
         if authorized(HasAuthKitRole('internal')):
             c.collections = model.getcollectionswithrole('internal')
             publiccollections = model.getcollectionswithrole('public')
-            c.collections.append(publiccollections)
+            c.collections = c.collections + publiccollections
             return render('/collections.mak')
         else:
             c.collections = model.getcollectionswithrole('public')

Modified: arkaiv/trunk/arkaiv/controllers/list.py
===================================================================
--- arkaiv/trunk/arkaiv/controllers/list.py	2009-09-28 05:57:38 UTC (rev 4038)
+++ arkaiv/trunk/arkaiv/controllers/list.py	2009-09-29 00:49:59 UTC (rev 4039)
@@ -1,7 +1,7 @@
 import logging
 
-from authkit.authorize.pylons_adaptors import authorize
-from authkit.permissions import RemoteUser, ValidAuthKitUser, UserIn
+from authkit.authorize.pylons_adaptors import authorize, authorized
+from authkit.permissions import HasAuthKitRole, RemoteUser, ValidAuthKitUser, UserIn
 from pylons import request, response, session, tmpl_context as c
 from pylons.controllers.util import abort, redirect_to
 
@@ -10,15 +10,31 @@
 log = logging.getLogger(__name__)
 
 class ListController(BaseController):
-#    @authorize(ValidAuthKitUser())
     def index(self):
-#        if request.environ.get("REMOTE_USER"):
+        if authorized(HasAuthKitRole('admin')):
             c.items = model.getallitems()
             return render('/mainpage.mak')
-#        else:
-#            response.status = "401 Not authenticated"
-#            return "You are not authenticated"
+        if authorized(HasAuthKitRole('internal')):
+            c.collections = model.getcollectionswithrole('internal')
+            publiccollections = model.getcollectionswithrole('public')
+            c.collections = c.collections + publiccollections
+            print "HOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO"
+            print c.collections
+        else:
+            c.collections = model.getcollectionswithrole('public')
+        c.items = [] 
+        allitems = []
+        for n in c.collections:
 
+            # A collection could be empty, and an empty list element causes 
+            # trouble
+            items = model.getitemsincollection(n['index'])
+            if (not items == []):
+                c.items = c.items + items
+            
+        return render('/mainpage.mak')
+             
+
     def signout(self):
         return "Successfully signed out!"
 

Modified: arkaiv/trunk/development.ini
===================================================================
--- arkaiv/trunk/development.ini	2009-09-28 05:57:38 UTC (rev 4038)
+++ arkaiv/trunk/development.ini	2009-09-29 00:49:59 UTC (rev 4039)
@@ -31,6 +31,7 @@
 authkit.cookie.signoutpath = /admin/logout
 authkit.form.authenticate.user.data = user:pylons user
                                       admin:pword admin
+                                      macuser:hoohaa internal
 
 # If you'd like to fine-tune the individual locations of the cache data dirs
 # for the Cache data, or the Session saves, un-comment the desired settings



More information about the commits mailing list