Skip to content

Commit bf7593c

Browse files
author
Richard Jones
committed
logout works better now
1 parent 67b8f06 commit bf7593c

File tree

3 files changed

+38
-7
lines changed

3 files changed

+38
-7
lines changed

roundup/cgi/client.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: client.py,v 1.3 2002-09-01 12:18:40 richard Exp $
1+
# $Id: client.py,v 1.4 2002-09-01 22:09:20 richard Exp $
22

33
__doc__ = """
44
WWW request handler (also used in the stand-alone server).
@@ -60,23 +60,33 @@ class Client:
6060
6161
Once a user logs in, they are assigned a session. The Client instance
6262
keeps the nodeid of the session as the "session" attribute.
63+
64+
Client attributes:
65+
"url" is the current url path
66+
"path" is the PATH_INFO inside the instance
67+
"base" is the base URL for the instance
6368
'''
6469

6570
def __init__(self, instance, request, env, form=None):
6671
hyperdb.traceMark()
6772
self.instance = instance
6873
self.request = request
6974
self.env = env
75+
7076
self.path = env['PATH_INFO']
7177
self.split_path = self.path.split('/')
7278
self.instance_path_name = env['INSTANCE_NAME']
79+
80+
# this is the base URL for this instance
7381
url = self.env['SCRIPT_NAME'] + '/' + self.instance_path_name
74-
machine = self.env['SERVER_NAME']
75-
port = self.env['SERVER_PORT']
76-
if port != '80': machine = machine + ':' + port
7782
self.base = urlparse.urlunparse(('http', env['HTTP_HOST'], url,
7883
None, None, None))
7984

85+
# request.path is the full request path
86+
x, x, path, x, x, x = urlparse.urlparse(request.path)
87+
self.url = urlparse.urlunparse(('http', env['HTTP_HOST'], path,
88+
None, None, None))
89+
8090
if form is None:
8191
self.form = cgi.FieldStorage(environ=env)
8292
else:

roundup/cgi/templating.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -851,11 +851,25 @@ def handleListCGIValue(value):
851851
else:
852852
return value.value.split(',')
853853

854-
# XXX This is starting to look a lot (in data terms) like the client object
855-
# itself!
856854
class HTMLRequest:
857855
''' The *request*, holding the CGI form and environment.
858856
857+
"form" the CGI form as a cgi.FieldStorage
858+
"env" the CGI environment variables
859+
"url" the current URL path for this request
860+
"base" the base URL for this instance
861+
"user" a HTMLUser instance for this user
862+
"classname" the current classname (possibly None)
863+
"template_type" the current template type (suffix, also possibly None)
864+
865+
Index args:
866+
"columns" dictionary of the columns to display in an index page
867+
"sort" index sort column (direction, column name)
868+
"group" index grouping property (direction, column name)
869+
"filter" properties to filter the index on
870+
"filterspec" values to filter the index on
871+
"search_text" text to perform a full-text search on for an index
872+
859873
'''
860874
def __init__(self, client):
861875
self.client = client
@@ -864,6 +878,7 @@ def __init__(self, client):
864878
self.form = client.form
865879
self.env = client.env
866880
self.base = client.base
881+
self.url = client.url
867882
self.user = HTMLUser(client)
868883

869884
# store the current class name and action
@@ -933,6 +948,7 @@ def __str__(self):
933948
d['env'] = e
934949
return '''
935950
form: %(form)s
951+
url: %(url)r
936952
base: %(base)r
937953
classname: %(classname)r
938954
template_type: %(template_type)r
@@ -971,6 +987,7 @@ def indexargs_form(self, columns=1, sort=1, group=1, filter=1,
971987
return '\n'.join(l)
972988

973989
def indexargs_href(self, url, args):
990+
''' embed the current index args in a URL '''
974991
l = ['%s=%s'%(k,v) for k,v in args.items()]
975992
if self.columns:
976993
l.append(':columns=%s'%(','.join(self.columns.keys())))
@@ -1040,6 +1057,9 @@ def batch(self):
10401057
# return the batch object
10411058
return Batch(self.client, self.classname, l, size, start)
10421059

1060+
1061+
# extend the standard ZTUtils Batch object to remove dependency on
1062+
# Acquisition and add a couple of useful methods
10431063
class Batch(ZTUtils.Batch):
10441064
def __init__(self, client, classname, l, size, start, end=0, orphan=0, overlap=0):
10451065
self.client = client

roundup/templates/classic/html/page

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@
5151
<tal:block tal:condition="python:request.user.username != 'anonymous'">
5252
<a tal:attributes="href string:issue?:sort=-activity&:group=priority&:filter=status,assignedto&:columns=id,activity,title,creator,priority&status=-1,1,2,3,4,5,6,7&assignedto=${request/user/id}">My Issues</a><br>
5353
<a tal:attributes="href string:user${request/user/id}">My Details</a><br>
54-
<a href="?:action=logout">Logout</a>
54+
<a tal:attributes="href python:request.indexargs_href(request.url,
55+
{':action':'logout'})">Logout</a>
5556
</tal:block>
5657
</p>
5758
</td>

0 commit comments

Comments
 (0)