GroupsDirectory

Exaple 3: Implementation example

Like in example 2 we'll continue work with the structure made in example 1. We want to implement this in a cgi-script. This is just a example and I will not write a whole script. I'll only point at the important points.
import cgi
import MySQLdb
import gd
.
# Lets assume that the cgi contains:
# user=marvin&passwd=BoriNg&mod=news&group=pub&action=write
#
.
# The user authentication occures here to verify password.
.
qAction = '%s.%s.%s' % (cgi['group'], cgi['mod'], cgi['action'])
.
# We'll get the GD from a db query instead of a file this time.
rights = gd.load(sql.execute('select pickle from gd where name="rights"') \
	 .fetchone()[0])
.
.
.
if not rights.isIn(user, qAction):
	print 'Content-type: text/html\n\nStep into my office.\n\nRegards\n\nZaphod')
.
.
.

Notes

This is one example. There can be as many implementations as there are people in the world I guess. And this in not the only way of usage. GD can be useful to host a virtual filesystem for instace.