Mercurial > p > roundup > code
comparison roundup/cgi/client.py @ 1552:68ef6deefcf1
cgi fixes
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Wed, 26 Mar 2003 03:35:00 +0000 |
| parents | 3fb2872f9b7d |
| children | b975da59cd11 |
comparison
equal
deleted
inserted
replaced
| 1551:9b9917b7719b | 1552:68ef6deefcf1 |
|---|---|
| 1 # $Id: client.py,v 1.109 2003-03-20 04:02:52 richard Exp $ | 1 # $Id: client.py,v 1.110 2003-03-26 03:35:00 richard Exp $ |
| 2 | 2 |
| 3 __doc__ = """ | 3 __doc__ = """ |
| 4 WWW request handler (also used in the stand-alone server). | 4 WWW request handler (also used in the stand-alone server). |
| 5 """ | 5 """ |
| 6 | 6 |
| 227 # now render the page | 227 # now render the page |
| 228 | 228 |
| 229 # we don't want clients caching our dynamic pages | 229 # we don't want clients caching our dynamic pages |
| 230 self.additional_headers['Cache-Control'] = 'no-cache' | 230 self.additional_headers['Cache-Control'] = 'no-cache' |
| 231 self.additional_headers['Pragma'] = 'no-cache' | 231 self.additional_headers['Pragma'] = 'no-cache' |
| 232 self.additional_headers['Expires'] = 'Thu, 1 Jan 1970 00:00:00 GMT' | 232 |
| 233 # expire this page 5 seconds from now | |
| 234 date = rfc822.formatdate(time.time() + 5) | |
| 235 self.additional_headers['Expires'] = date | |
| 233 | 236 |
| 234 # render the content | 237 # render the content |
| 235 self.write(self.renderContext()) | 238 self.write(self.renderContext()) |
| 236 except Redirect, url: | 239 except Redirect, url: |
| 237 # let's redirect - if the url isn't None, then we need to do | 240 # let's redirect - if the url isn't None, then we need to do |
| 461 lmtt = time.gmtime(lmt)[:6] | 464 lmtt = time.gmtime(lmt)[:6] |
| 462 if lmtt <= ims: | 465 if lmtt <= ims: |
| 463 raise NotModified | 466 raise NotModified |
| 464 | 467 |
| 465 # we just want to serve up the file named | 468 # we just want to serve up the file named |
| 466 mt = mimetypes.guess_type(str(file))[0] | 469 file = str(file) |
| 470 mt = mimetypes.guess_type(file)[0] | |
| 467 if not mt: | 471 if not mt: |
| 468 mt = 'text/plain' | 472 if file.endswith('.css'): |
| 473 mt = 'text/css' | |
| 474 else: | |
| 475 mt = 'text/plain' | |
| 469 self.additional_headers['Content-Type'] = mt | 476 self.additional_headers['Content-Type'] = mt |
| 470 self.additional_headers['Last-Modifed'] = rfc822.formatdate(lmt) | 477 self.additional_headers['Last-Modifed'] = rfc822.formatdate(lmt) |
| 471 self.write(open(filename, 'rb').read()) | 478 self.write(open(filename, 'rb').read()) |
| 472 | 479 |
| 473 def renderContext(self): | 480 def renderContext(self): |
| 866 ''' | 873 ''' |
| 867 if self.form.has_key('otk'): | 874 if self.form.has_key('otk'): |
| 868 # pull the rego information out of the otk database | 875 # pull the rego information out of the otk database |
| 869 otk = self.form['otk'].value | 876 otk = self.form['otk'].value |
| 870 uid = self.db.otks.get(otk, 'uid') | 877 uid = self.db.otks.get(otk, 'uid') |
| 878 if uid is None: | |
| 879 self.error_message.append('Invalid One Time Key!') | |
| 880 return | |
| 871 | 881 |
| 872 # re-open the database as "admin" | 882 # re-open the database as "admin" |
| 873 if self.user != 'admin': | 883 if self.user != 'admin': |
| 874 self.opendb('admin') | 884 self.opendb('admin') |
| 875 | 885 |
| 1303 if minifield.value: | 1313 if minifield.value: |
| 1304 break | 1314 break |
| 1305 else: | 1315 else: |
| 1306 continue | 1316 continue |
| 1307 else: | 1317 else: |
| 1308 if not self.form[key].value: continue | 1318 if not self.form[key].value: |
| 1319 continue | |
| 1309 self.form.value.append(cgi.MiniFieldStorage('@filter', key)) | 1320 self.form.value.append(cgi.MiniFieldStorage('@filter', key)) |
| 1310 | 1321 |
| 1311 # handle saving the query params | 1322 # handle saving the query params |
| 1312 if queryname: | 1323 if queryname: |
| 1313 # parse the environment and figure what the query _is_ | 1324 # parse the environment and figure what the query _is_ |
