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, '', c='Internal news admins')
>>> root.create(gd.GROUP, '', c='Public news admins')
>>> root.create(gd.GROUP, '', c='Internal news delete permission')
>>> root.create(gd.GROUP, '', c='Internal news write permission')
>>> root.create(gd.GROUP, '', c='Internal news read permission')
>>> root.create(gd.GROUP, '', c='Public news delete permission')
>>> root.create(gd.GROUP, '', c='Public news write permission')
>>> root.create(gd.GROUP, '', 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', '')
>>> root.addMembers('', '')
>>> root.addMembers(('', 'marvin'), '')
>>> root.addMembers(('', 'ford'), '')
>>> root.addMembers(('ford', 'marvin', 'adm.publ'), '')
>>> root.addMembers('', '')
>>> root.addMembers(('', 'arthur'), '')
>>> root.addMembers('public', '')


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 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.