GroupsDirectory

Exaple 1: Creating a structure

The following example describes how to create a structure in GD. Let us assume that we have a web-forum with a internal news-forum for the forum admins. And a public news-forum for the rest of the world. We've also got five persons who is to moderate this service to the public.
When creating the news-application we decide to put restricion levels for remove, write and read. We separate remove and write to minimize Murphy. After all, the publishers are users.
>>> import gd
>>> root = gd.root('public')
>>> root.create(gd.GROUP, 'admins', c='Administrators')
>>> root.create(gd.GROUP, 'adm.publ', c='Publisher Admins')
>>> root.create(gd.GROUP, 'int.news.adm', c='Internal news admins')
>>> root.create(gd.GROUP, 'pub.news.adm', c='Public news admins')
>>> root.create(gd.GROUP, 'int.news.delete', c='Internal news delete permission')
>>> root.create(gd.GROUP, 'int.news.write', c='Internal news write permission')
>>> root.create(gd.GROUP, 'int.news.read', c='Internal news read permission')
>>> root.create(gd.GROUP, 'pub.news.delete', c='Public news delete permission')
>>> root.create(gd.GROUP, 'pub.news.write', c='Public news write permission')
>>> root.create(gd.GROUP, 'pub.news.read', c='Public news read permission')
>>> root.create(gd.ITEM, 'zaphod', 'Former President')
>>> root.create(gd.ITEM, 'trillian', 'Zaphods friend')
>>> root.create(gd.ITEM, 'marvin', 'Depressed robot')
>>> root.create(gd.ITEM, 'ford', 'Hitchhiker')
>>> root.create(gd.ITEM, 'arthur', 'Earth creature')
>>> root.addMembers('zaphod', 'admins')
>>> root.addMembers(('admins', 'trillian'), 'adm.publ')
>>> root.addMembers('adm.publ', 'int.news.adm')
>>> root.addMembers('int.news.adm', 'int.news.delete')
>>> root.addMembers(('int.news.delete', 'marvin'), 'int.news.write')
>>> root.addMembers(('pub.news.write', 'ford'), 'int.news.read')
>>> root.addMembers(('ford', 'marvin', 'adm.publ'), 'pub.news.adm')
>>> root.addMembers('pub.news.adm', 'pub.news.delete')
>>> root.addMembers(('pub.news.delete', 'arthur'), 'pub.news.write')
>>> root.addMembers('public', 'pub.news.read')
>>> root.save('cmsrights.pic')

Explanation

First of all. For the whole content management system we've got an administrator. In this case it's Zaphod. Since Zaphod is a very busy man with developing a CMS software. He wants a person who can administrate all the news-forums. That would in this case be Trillian.
Trillian in her turn have given Marvin the right to write news in the internal news-forum. She doesn't allow him to delete posts tough. Despite his intelligence he's often depressed and can do unforseen things when questioning if there is a point with a news-forum.
Trillian doesn't have unlimited time tough. So Zaphod lets Marvin and Ford to help the Publisher admins out in administer the public news forum. They get pub.news.adm permissions. Then we've got Arthur who are allowed to write posts in the public news forum. Last but not least the public are allowed to read the public news.