Skip to content

Commit 9df73ce

Browse files
author
Richard Jones
committed
Pushed the base code for the extended schema CGI interface back...
...into the code cgi_client module so that future updates will be less painful. Also removed a debugging print statement from cgi_client.
1 parent defcced commit 9df73ce

File tree

3 files changed

+107
-78
lines changed

3 files changed

+107
-78
lines changed

roundup/cgi_client.py

Lines changed: 78 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: cgi_client.py,v 1.29 2001-10-09 07:25:59 richard Exp $
18+
# $Id: cgi_client.py,v 1.30 2001-10-09 07:38:58 richard Exp $
1919

2020
import os, cgi, pprint, StringIO, urlparse, re, traceback, mimetypes
2121
import base64, Cookie, time
@@ -30,7 +30,6 @@ class NotFound(ValueError):
3030

3131
class Client:
3232
'''
33-
3433
A note about login
3534
------------------
3635
@@ -504,7 +503,6 @@ def login_action(self, message=None):
504503

505504
# and that the password is correct
506505
pw = self.db.user.get(uid, 'password')
507-
print password, pw, `pw`
508506
if password != self.db.user.get(uid, 'password'):
509507
self.make_user_anonymous()
510508
return self.login(message='Incorrect password')
@@ -649,6 +647,79 @@ def main(self, dre=re.compile(r'([^\d]+)(\d+)'),
649647
def __del__(self):
650648
self.db.close()
651649

650+
651+
class ExtendedClient(Client):
652+
'''Includes pages and page heading information that relate to the
653+
extended schema.
654+
'''
655+
showsupport = Client.shownode
656+
showtimelog = Client.shownode
657+
newsupport = Client.newnode
658+
newtimelog = Client.newnode
659+
660+
default_index_sort = ['-activity']
661+
default_index_group = ['priority']
662+
default_index_filter = []
663+
default_index_columns = ['activity','status','title','assignedto']
664+
default_index_filterspec = {'status': ['1', '2', '3', '4', '5', '6', '7']}
665+
666+
def pagehead(self, title, message=None):
667+
url = self.env['SCRIPT_NAME'] + '/' #self.env.get('PATH_INFO', '/')
668+
machine = self.env['SERVER_NAME']
669+
port = self.env['SERVER_PORT']
670+
if port != '80': machine = machine + ':' + port
671+
base = urlparse.urlunparse(('http', machine, url, None, None, None))
672+
if message is not None:
673+
message = '<div class="system-msg">%s</div>'%message
674+
else:
675+
message = ''
676+
style = open(os.path.join(self.TEMPLATES, 'style.css')).read()
677+
user_name = self.user or ''
678+
if self.user == 'admin':
679+
admin_links = ' | <a href="list_classes">Class List</a>'
680+
else:
681+
admin_links = ''
682+
if self.user not in (None, 'anonymous'):
683+
userid = self.db.user.lookup(self.user)
684+
user_info = '''
685+
<a href="issue?assignedto=%s&status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=priority">My Issues</a> |
686+
<a href="support?assignedto=%s&status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=customername">My Support</a> |
687+
<a href="user%s">My Details</a> | <a href="logout">Logout</a>
688+
'''%(userid, userid, userid)
689+
else:
690+
user_info = '<a href="login">Login</a>'
691+
if self.user is not None:
692+
add_links = '''
693+
| Add
694+
<a href="newissue">Issue</a>,
695+
<a href="newsupport">Support</a>,
696+
<a href="newuser">User</a>
697+
'''
698+
else:
699+
add_links = ''
700+
self.write('''<html><head>
701+
<title>%s</title>
702+
<style type="text/css">%s</style>
703+
</head>
704+
<body bgcolor=#ffffff>
705+
%s
706+
<table width=100%% border=0 cellspacing=0 cellpadding=2>
707+
<tr class="location-bar"><td><big><strong>%s</strong></big></td>
708+
<td align=right valign=bottom>%s</td></tr>
709+
<tr class="location-bar">
710+
<td align=left>All
711+
<a href="issue?status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=priority">Issues</a>,
712+
<a href="support?status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=customername">Support</a>
713+
| Unassigned
714+
<a href="issue?assignedto=admin&status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=priority">Issues</a>,
715+
<a href="support?assignedto=admin&status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=customername">Support</a>
716+
%s
717+
%s</td>
718+
<td align=right>%s</td>
719+
</table>
720+
'''%(title, style, message, title, user_name, add_links, admin_links,
721+
user_info))
722+
652723
def parsePropsFromForm(cl, form, nodeid=0):
653724
'''Pull properties for the given class out of the form.
654725
'''
@@ -706,6 +777,10 @@ def parsePropsFromForm(cl, form, nodeid=0):
706777

707778
#
708779
# $Log: not supported by cvs2svn $
780+
# Revision 1.29 2001/10/09 07:25:59 richard
781+
# Added the Password property type. See "pydoc roundup.password" for
782+
# implementation details. Have updated some of the documentation too.
783+
#
709784
# Revision 1.28 2001/10/08 00:34:31 richard
710785
# Change message was stuffing up for multilinks with no key property.
711786
#

roundup/templates/classic/interfaces.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,13 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: interfaces.py,v 1.6 2001-08-07 00:24:43 richard Exp $
19-
20-
import urlparse, os
18+
# $Id: interfaces.py,v 1.7 2001-10-09 07:38:58 richard Exp $
2119

2220
import instance_config
2321
from roundup import cgi_client, mailgw
2422

2523
class Client(cgi_client.Client):
26-
''' derives basic mail gateway implementation from the standard module,
24+
''' derives basic CGI implementation from the standard module,
2725
with any specific extensions
2826
'''
2927
TEMPLATES = instance_config.TEMPLATES
@@ -38,6 +36,9 @@ class MailGW(mailgw.MailGW):
3836

3937
#
4038
# $Log: not supported by cvs2svn $
39+
# Revision 1.6 2001/08/07 00:24:43 richard
40+
# stupid typo
41+
#
4142
# Revision 1.5 2001/08/07 00:15:51 richard
4243
# Added the copyright/license notice to (nearly) all files at request of
4344
# Bizar Software.

roundup/templates/extended/interfaces.py

Lines changed: 24 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -15,83 +15,16 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: interfaces.py,v 1.10 2001-10-05 02:23:24 richard Exp $
18+
# $Id: interfaces.py,v 1.11 2001-10-09 07:38:58 richard Exp $
1919

20-
import instance_config, urlparse, os
20+
import instance_config
2121
from roundup import cgi_client, mailgw
2222

23-
class Client(cgi_client.Client):
24-
''' derives basic mail gateway implementation from the standard module,
23+
class Client(cgi_client.ExtendedClient):
24+
''' derives basic CGI implementation from the standard module,
2525
with any specific extensions
2626
'''
2727
TEMPLATES = instance_config.TEMPLATES
28-
showsupport = cgi_client.Client.shownode
29-
showtimelog = cgi_client.Client.shownode
30-
newsupport = cgi_client.Client.newnode
31-
newtimelog = cgi_client.Client.newnode
32-
33-
default_index_sort = ['-activity']
34-
default_index_group = ['priority']
35-
default_index_filter = []
36-
default_index_columns = ['activity','status','title','assignedto']
37-
default_index_filterspec = {'status': ['1', '2', '3', '4', '5', '6', '7']}
38-
39-
def pagehead(self, title, message=None):
40-
url = self.env['SCRIPT_NAME'] + '/' #self.env.get('PATH_INFO', '/')
41-
machine = self.env['SERVER_NAME']
42-
port = self.env['SERVER_PORT']
43-
if port != '80': machine = machine + ':' + port
44-
base = urlparse.urlunparse(('http', machine, url, None, None, None))
45-
if message is not None:
46-
message = '<div class="system-msg">%s</div>'%message
47-
else:
48-
message = ''
49-
style = open(os.path.join(self.TEMPLATES, 'style.css')).read()
50-
user_name = self.user or ''
51-
if self.user == 'admin':
52-
admin_links = ' | <a href="list_classes">Class List</a>'
53-
else:
54-
admin_links = ''
55-
if self.user not in (None, 'anonymous'):
56-
userid = self.db.user.lookup(self.user)
57-
user_info = '''
58-
<a href="issue?assignedto=%s&status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=priority">My Issues</a> |
59-
<a href="support?assignedto=%s&status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=customername">My Support</a> |
60-
<a href="user%s">My Details</a> | <a href="logout">Logout</a>
61-
'''%(userid, userid, userid)
62-
else:
63-
user_info = '<a href="login">Login</a>'
64-
if self.user is not None:
65-
add_links = '''
66-
| Add
67-
<a href="newissue">Issue</a>,
68-
<a href="newsupport">Support</a>,
69-
<a href="newuser">User</a>
70-
'''
71-
else:
72-
add_links = ''
73-
self.write('''<html><head>
74-
<title>%s</title>
75-
<style type="text/css">%s</style>
76-
</head>
77-
<body bgcolor=#ffffff>
78-
%s
79-
<table width=100%% border=0 cellspacing=0 cellpadding=2>
80-
<tr class="location-bar"><td><big><strong>%s</strong></big></td>
81-
<td align=right valign=bottom>%s</td></tr>
82-
<tr class="location-bar">
83-
<td align=left>All
84-
<a href="issue?status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=priority">Issues</a>,
85-
<a href="support?status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=customername">Support</a>
86-
| Unassigned
87-
<a href="issue?assignedto=admin&status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=priority">Issues</a>,
88-
<a href="support?assignedto=admin&status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=customername">Support</a>
89-
%s
90-
%s</td>
91-
<td align=right>%s</td>
92-
</table>
93-
'''%(title, style, message, title, user_name, add_links, admin_links,
94-
user_info))
9528

9629
class MailGW(mailgw.MailGW):
9730
''' derives basic mail gateway implementation from the standard module,
@@ -103,6 +36,26 @@ class MailGW(mailgw.MailGW):
10336

10437
#
10538
# $Log: not supported by cvs2svn $
39+
# Revision 1.10 2001/10/05 02:23:24 richard
40+
# . roundup-admin create now prompts for property info if none is supplied
41+
# on the command-line.
42+
# . hyperdb Class getprops() method may now return only the mutable
43+
# properties.
44+
# . Login now uses cookies, which makes it a whole lot more flexible. We can
45+
# now support anonymous user access (read-only, unless there's an
46+
# "anonymous" user, in which case write access is permitted). Login
47+
# handling has been moved into cgi_client.Client.main()
48+
# . The "extended" schema is now the default in roundup init.
49+
# . The schemas have had their page headings modified to cope with the new
50+
# login handling. Existing installations should copy the interfaces.py
51+
# file from the roundup lib directory to their instance home.
52+
# . Incorrectly had a Bizar Software copyright on the cgitb.py module from
53+
# Ping - has been removed.
54+
# . Fixed a whole bunch of places in the CGI interface where we should have
55+
# been returning Not Found instead of throwing an exception.
56+
# . Fixed a deviation from the spec: trying to modify the 'id' property of
57+
# an item now throws an exception.
58+
#
10659
# Revision 1.9 2001/08/07 00:24:43 richard
10760
# stupid typo
10861
#

0 commit comments

Comments
 (0)