Update of /cvsroot/tmda/tmda/contrib/cgi
In directory sc8-pr-cvs1:/tmp/cvs-serv24565
Added Files:
tmda-cgi.py
Log Message:
Top-level Python CGI code. Called by actual CGI which is written in C.
tmda-cgi.py processes forms and calls sessioning code to transition smoothly
from page to page. tmda-cgi.py tests the form field "cmd" and call the ap-
propriate HTML page.
--- NEW FILE ---
#!/usr/bin/env python
#
# Copyright (C) 2002 Gre7g Luterman <[EMAIL PROTECTED]>
#
# This file is part of TMDA.
#
# TMDA is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version. A copy of this license should
# be included in the file COPYING.
#
# TMDA is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with TMDA; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""Web interface to TMDA tools.
This program is expected to be called as a CGI. See contrib/cgi/INSTALL for
specific instructions on using this file.
Fields:
Login.Show(Msg)
Form: None
PVars: None
Pending.Show()
Form: [user, password], cmd=view, [subcmd=first|prev|next|last|batch]
[a#=X|r|d|w|b, m#]
PVars: UID, GID, MiscUID, MiscGID, User, HOME, SortDir, Pager
View.Show()
Form: cmd=view, [subcmd=first|prev|next|last|delete|release|white|black],
[headers=short|all], [msgid]
PVars: UID, GID, MiscUID, MiscGID, User, HOME, Headers, MsgID
"""
import cgi
import cgitb; cgitb.enable()
import os
import pwd
import Session
# Process any CGI fields
Form = cgi.FieldStorage()
# Get any persistent variables
PVars = Session.Session(Form)
def main():
"Figure out which page we're on and pass control along."
# Logged in yet?
if not PVars.has_key("UID"):
import Login
if Form.has_key("cmd"):
Login.Show("Wrong password. Try again.")
else: Login.Show()
elif Form.has_key("cmd"):
# Just log in?
if Form.has_key("user"):
PVars["SortDir"] = "desc"
PVars["Pager"] = 0
PVars["Headers"] = "short"
PVars.Save()
import CgiUtil
import Pending
import View
# Share "globals"
Pending.PVars = PVars
Pending.Form = Form
View.PVars = PVars
View.Form = Form
CgiUtil.PVars = PVars
# View?
if Form["cmd"].value == "list":
Pending.Show()
elif Form["cmd"].value == "view":
if Form.has_key("msgid"):
PVars["MsgID"] = Form["msgid"].value
if Form.has_key("headers"):
PVars["Headers"] = Form["headers"].value
PVars.Save()
View.Show()
else: print "Content-type: text/html\n\nNo command.<p>"
#print "<hr> Everything below this line is experimental.<p>"
#cgi.print_environ()
#cgi.print_form(Form)
#cgi.print_form(PVars)
# This is the end my friend.
if __name__ == '__main__':
main()
_______________________________________
tmda-cvs mailing list
http://tmda.net/lists/listinfo/tmda-cvs