Mercurial > p > roundup > code
changeset 1004:5f12d3259f31
logout works better now
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Sun, 01 Sep 2002 22:09:20 +0000 |
| parents | f89b8d32291b |
| children | efa19bdad6c3 |
| files | roundup/cgi/client.py roundup/cgi/templating.py roundup/templates/classic/html/page |
| diffstat | 3 files changed, 38 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/roundup/cgi/client.py Sun Sep 01 12:18:41 2002 +0000 +++ b/roundup/cgi/client.py Sun Sep 01 22:09:20 2002 +0000 @@ -1,4 +1,4 @@ -# $Id: client.py,v 1.3 2002-09-01 12:18:40 richard Exp $ +# $Id: client.py,v 1.4 2002-09-01 22:09:20 richard Exp $ __doc__ = """ WWW request handler (also used in the stand-alone server). @@ -60,6 +60,11 @@ Once a user logs in, they are assigned a session. The Client instance keeps the nodeid of the session as the "session" attribute. + + Client attributes: + "url" is the current url path + "path" is the PATH_INFO inside the instance + "base" is the base URL for the instance ''' def __init__(self, instance, request, env, form=None): @@ -67,16 +72,21 @@ self.instance = instance self.request = request self.env = env + self.path = env['PATH_INFO'] self.split_path = self.path.split('/') self.instance_path_name = env['INSTANCE_NAME'] + + # this is the base URL for this instance url = self.env['SCRIPT_NAME'] + '/' + self.instance_path_name - machine = self.env['SERVER_NAME'] - port = self.env['SERVER_PORT'] - if port != '80': machine = machine + ':' + port self.base = urlparse.urlunparse(('http', env['HTTP_HOST'], url, None, None, None)) + # request.path is the full request path + x, x, path, x, x, x = urlparse.urlparse(request.path) + self.url = urlparse.urlunparse(('http', env['HTTP_HOST'], path, + None, None, None)) + if form is None: self.form = cgi.FieldStorage(environ=env) else:
--- a/roundup/cgi/templating.py Sun Sep 01 12:18:41 2002 +0000 +++ b/roundup/cgi/templating.py Sun Sep 01 22:09:20 2002 +0000 @@ -851,11 +851,25 @@ else: return value.value.split(',') -# XXX This is starting to look a lot (in data terms) like the client object -# itself! class HTMLRequest: ''' The *request*, holding the CGI form and environment. + "form" the CGI form as a cgi.FieldStorage + "env" the CGI environment variables + "url" the current URL path for this request + "base" the base URL for this instance + "user" a HTMLUser instance for this user + "classname" the current classname (possibly None) + "template_type" the current template type (suffix, also possibly None) + + Index args: + "columns" dictionary of the columns to display in an index page + "sort" index sort column (direction, column name) + "group" index grouping property (direction, column name) + "filter" properties to filter the index on + "filterspec" values to filter the index on + "search_text" text to perform a full-text search on for an index + ''' def __init__(self, client): self.client = client @@ -864,6 +878,7 @@ self.form = client.form self.env = client.env self.base = client.base + self.url = client.url self.user = HTMLUser(client) # store the current class name and action @@ -933,6 +948,7 @@ d['env'] = e return ''' form: %(form)s +url: %(url)r base: %(base)r classname: %(classname)r template_type: %(template_type)r @@ -971,6 +987,7 @@ return '\n'.join(l) def indexargs_href(self, url, args): + ''' embed the current index args in a URL ''' l = ['%s=%s'%(k,v) for k,v in args.items()] if self.columns: l.append(':columns=%s'%(','.join(self.columns.keys()))) @@ -1040,6 +1057,9 @@ # return the batch object return Batch(self.client, self.classname, l, size, start) + +# extend the standard ZTUtils Batch object to remove dependency on +# Acquisition and add a couple of useful methods class Batch(ZTUtils.Batch): def __init__(self, client, classname, l, size, start, end=0, orphan=0, overlap=0): self.client = client
--- a/roundup/templates/classic/html/page Sun Sep 01 12:18:41 2002 +0000 +++ b/roundup/templates/classic/html/page Sun Sep 01 22:09:20 2002 +0000 @@ -51,7 +51,8 @@ <tal:block tal:condition="python:request.user.username != 'anonymous'"> <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> <a tal:attributes="href string:user${request/user/id}">My Details</a><br> - <a href="?:action=logout">Logout</a> + <a tal:attributes="href python:request.indexargs_href(request.url, + {':action':'logout'})">Logout</a> </tal:block> </p> </td>
