Example 2: Querying a structure
Let us use the structure created in Example 1. Simple queries can be made
>>> import gd
>>> root = gd.loadFile('cmsrights.pic')
Is Zaphod a member in int.news.read?
>>> root.isMember('zaphod', 'int.news.read')
Ok, is he related somehow to int.news.read?
>>> root.isIn('zaphod', 'int.news.read')
Which groups is he a member of anyway?
Who is public news forum administrator, (pub.news.adm)?
['ford', 'marvin', 'adm.publ']
Is Trillian related to, (allowed in...) pub.news.adm?
>>> root.isIn('trillian', 'pub.news.adm')
Is Arthur allowed in pub.news.read?
>>> root.isIn('arthur', 'pub.news.read')
Who is member of pub.news.read?
Who is member of public?
['public', 'admins', 'adm.publ', 'int.news.adm', 'pub.news.adm',
'int.news.delete', 'int.news.write', 'int.news.read', 'pub.news.delete',
'pub.news.write', 'pub.news.read', 'zaphod', 'trillian', 'marvin', 'ford',