|
Revision 3, 0.9 kB
(checked in by davea, 3 years ago)
|
re-jig to use mod_python instead of CGI. now does proper authentication, meaning anyone with a valid IMAP account can login
|
- Property svn:executable set to
*
|
| Line | |
|---|
| 1 |
from mod_python import psp |
|---|
| 2 |
import imaplib |
|---|
| 3 |
import os |
|---|
| 4 |
|
|---|
| 5 |
import webmail |
|---|
| 6 |
|
|---|
| 7 |
def index(req): |
|---|
| 8 |
req.content_type = "text/html" |
|---|
| 9 |
passwd = req.get_basic_auth_pw() |
|---|
| 10 |
user = req.user |
|---|
| 11 |
wm = webmail.Webmail(user, passwd, req) |
|---|
| 12 |
|
|---|
| 13 |
if req.form.has_key("folder"): |
|---|
| 14 |
wm.set_folder(req.form['folder']) |
|---|
| 15 |
|
|---|
| 16 |
vars = {'folders': wm.get_folders(), |
|---|
| 17 |
'folder': wm.current_folder, |
|---|
| 18 |
'mainpage': wm.get_messages(), |
|---|
| 19 |
} |
|---|
| 20 |
|
|---|
| 21 |
if req.form.has_key("msg"): |
|---|
| 22 |
vars['message'] = wm.get_message(req.form['msg']) |
|---|
| 23 |
else: |
|---|
| 24 |
vars['message'] = "" |
|---|
| 25 |
|
|---|
| 26 |
return psp.PSP(req, "templates/main.html", vars=vars) |
|---|
| 27 |
|
|---|
| 28 |
def inc(req): |
|---|
| 29 |
file_path = os.path.dirname(req.canonical_filename) + "/_inc" + req.path_info |
|---|
| 30 |
file_type = file_path.split(".")[-1:][0] |
|---|
| 31 |
|
|---|
| 32 |
if file_type == "css": |
|---|
| 33 |
req.content_type = "text/css" |
|---|
| 34 |
elif file_type == "js": |
|---|
| 35 |
req.content_type = "text/javascript" |
|---|
| 36 |
req.flush() |
|---|
| 37 |
req.sendfile(file_path) |
|---|