[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[minion-cvs] Implement directory CGI



Update of /home/minion/cvsroot/src/minion/lib/mixminion/directory
In directory moria.mit.edu:/tmp/cvs-serv8954/lib/mixminion/directory

Modified Files:
	DirCGI.py Directory.py 
Log Message:
Implement directory CGI

Index: DirCGI.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/directory/DirCGI.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- DirCGI.py	23 May 2003 22:49:30 -0000	1.1
+++ DirCGI.py	27 May 2003 04:56:48 -0000	1.2
@@ -9,11 +9,38 @@
 __all__ = [ ]
 
 DIRECTORY_BASE = None
-IDCACHE_FILE = None
-QUEUE_BASE = None
 
-def addServer(text, base):
-    DIRECTORY_
-    #XXXX write more.
+import cgi
+import os
+import sys
+from mixminion.directory.Directory import Directory
 
-              
+assert sys.version_info[:3] >= (2,2,0)
+
+try:
+    import cgitb; cgitb.enable()
+except ImportError:
+    pass
+
+def err(s):
+    print "Status: 0\nMessage:",s
+    sys.exit(0)
+
+print "Content-type: text/plain\n\n"
+
+form = cgi.FieldStorage()
+if not form.has_key['desc']:
+    err("no desc field found")
+
+desc = form['desc']
+
+if type(desc) == type([]):
+    err("too many desc fields")
+
+d = Directory(location=DIRECTORY_BASE)
+inbox = d.getInbox()
+
+address = "<%s:%s>" % (os.environ.get("REMOTE_ADDR"),
+                       os.environ.get("REMOTE_PORT"))
+
+inbox.receiveServer(desc, address)

Index: Directory.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/directory/Directory.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- Directory.py	26 May 2003 21:08:13 -0000	1.3
+++ Directory.py	27 May 2003 04:56:48 -0000	1.4
@@ -19,9 +19,13 @@
      formatBase64, writePickled, readPickled
 
 class Directory:
-    def __init__(self, config):
+    def __init__(self, config=None, location=None):
         self.config = config
-        self.location = config['Directory-Store']['Homedir']
+        if config and not location:
+            self.location = config['Directory-Store']['Homedir']
+        else:
+            self.location = location
+        assert location
         self.inboxBase = os.path.join(self.location, "inbox")
         self.directoryBase = os.path.join(self.location, "dir")
         self.cacheFile = os.path.join(self.location, "identity_cache")