示例#1
0
    def test_permission_register(self):
        import ptah

        perm = ptah.Permission('perm', 'Permission', 'Test permission')
        self.init_ptah()

        self.assertTrue(perm == 'perm')
        self.assertTrue(perm.title == 'Permission')
        self.assertTrue(perm.description == 'Test permission')
        self.assertTrue(ptah.get_permissions()['perm'] is perm)
示例#2
0
import ptah

View = ptah.Permission('ptahcms:ViewContent', 'View content')
AddContent = ptah.Permission('ptahcms:AddContent', 'Add content')
ModifyContent = ptah.Permission('ptahcms:ModifyContent', 'Modify content')
RenameContent = ptah.Permission('ptahcms:RenameContent', 'Rename content')
DeleteContent = ptah.Permission('ptahcms:DeleteContent', 'Delete content')
ShareContent = ptah.Permission('ptahcms:ShareContent', 'Share content')
示例#3
0
ptah.Everyone.allow(ptah.cms.View)
ptah.Authenticated.allow(ptah.cms.AddContent)

Viewer = ptah.Role('viewer', 'Viewer')
Viewer.allow(ptah.cms.View)

Editor = ptah.Role('editor', 'Editor')
Editor.allow(ptah.cms.View, ptah.cms.ModifyContent)

Manager = ptah.Role('manager', 'Manager')
Manager.allow(ptah.cms.ALL_PERMISSIONS)

ptah.Owner.allow(ptah.cms.DeleteContent)

# permissions
AddTheme = ptah.Permission('ploud:AddTheme', 'Add theme')
AddThemeFile = ptah.Permission('ploud:AddFile', 'Add theme file')
RetractTheme = ptah.Permission('ploud:RetractTheme', 'Retract theme')
ManageGallery = ptah.Permission('ploud:ManageGallery', 'Manage gallery')

# Gallery ACL
GALLERY_ACL = ptah.ACL('ploud-themegallery', 'Ploud theme gallery ACL')
GALLERY_ACL.allow(ptah.Everyone, ptah.cms.View)
GALLERY_ACL.allow(ptah.Authenticated, AddTheme)
GALLERY_ACL.allow(ptah.Authenticated, ptah.cms.View)
GALLERY_ACL.allow(ptah.Owner, AddThemeFile)
GALLERY_ACL.allow(ptah.Owner, ptah.cms.ModifyContent)
GALLERY_ACL.allow(ptah.Owner, ptah.cms.DeleteContent)
GALLERY_ACL.allow(Manager, ptah.cms.ALL_PERMISSIONS)

# ACL for private state
示例#4
0
""" app permissions and roles """
import ptah
import ptahcms

AddPage = ptah.Permission('ptah_minicms: Add page', 'Add page')
AddFile = ptah.Permission('ptah_minicms: Add file', 'Add file')
AddFolder = ptah.Permission('ptah_minicms: Add folder', 'Add folder')

ptah.Everyone.allow(ptahcms.View)
ptah.Authenticated.allow(ptahcms.AddContent)

Viewer = ptah.Role('viewer', 'Viewer')
Viewer.allow(ptahcms.View)

Editor = ptah.Role('editor', 'Editor')
Editor.allow(ptahcms.View, ptahcms.ModifyContent)

Manager = ptah.Role('manager', 'Manager')
Manager.allow(ptahcms.ALL_PERMISSIONS)

ptah.Owner.allow(ptahcms.DeleteContent)
示例#5
0
    def test_permission_register_same_name(self):
        ptah.Permission('perm', 'Permission1')
        ptah.Permission('perm', 'Permission2')

        self.assertRaises(ConfigurationConflictError, self.init_ptah)
示例#6
0
import ptah

View = ptah.Permission('ptah:View', 'View')
AddContent = ptah.Permission('ptah-cms:AddContent', 'Add content')
ModifyContent = ptah.Permission('ptah-cms:EditContent', 'Modify content')
DeleteContent = ptah.Permission('ptah-cms:DeleteContent', 'Delete content')
ShareContent = ptah.Permission('ptah-cms:ShareContent', 'Share content')