from mk_simple_certs import get_cert_filenames
server_name = 'chem_web'
-__version__ = "0.2"
+__version__ = "0.3"
## For web.py, when a URL matches '/view', handle with class 'view'
# when it matches '/edit', handle with class 'edit',
update = False
for field in db.field_list() :
if newvals[field] != record[field] :
+ # TODO: add validation!
update=True
record[field] = newvals[field]
if 'MSDS source' in newvals :
if name == 'door_warning.pdf' :
path = dgen.door_warning()
print file(path, 'rb').read() ,
-
+ def POST(self, name):
+ """
+ Read the form input and print the appropriate file.
+ """
+ db._refresh()
+ formdata = web.input()
+ user_regexp = formdata['regexp']
+ regexp = re.compile(user_regexp, re.I) # Case insensitive
+ path = dgen.door_warning(lambda r: regexp.match(r['Location']))
+ print file(path, 'rb').read() ,
class login (object) :
"Print an alphabetized index of all existing pages"
' <head>\n'
' </head>\n'
' <body>\n'
+ ' <p>\n'
' <a href="/docs/inventory.pdf">Inventory</a>\n'
' in accordance with the \n'
' <a href="http://www.drexelsafetyandhealth.com/lab-chem.htm#chpe7">\n'
' and \n'
' <a href="http://www.drexelsafetyandhealth.com/lab-chem.htm#chpe10">E-10</a>\n'
' .<br>\n'
+ ' </p>\n'
+ ' <p>\n'
+ ' For door warnings for subsections of the whole room,\n'
+ ' please give a location regexp in the form below.\n'
+ ' For example: ".*liquids" or "refrigerator".\n'
+ ' </p>\n'
+ ' <form action="" method="post" enctype="multipart/form-data">\n'
+ ' <table>\n'
+ ' <tr><td>Location regexp</td><td>:</td>\n'
+ ' <td><input type="text" size="50" id="regexp" name="regexp"></td></tr>\n'
+ ' </table>\n'
+ ' <input type="submit" value="Submit" />\n'
+ ' </form>\n'
' </body>\n'
'</html>\n')
file(self.dir+'docs.html', 'w').write(docs)
## How we have to start it now
webpy_func = web.webpyfunc(urls, globals(), False)
wsgi_func = web.wsgifunc(webpy_func)
- web.httpserver.runsecure(wsgi_func,
+ web.httpserver.runsimple(wsgi_func,
web.validip(self.options.ip),
ssl_private_key_filename=self.pkey_file,
ssl_certificate_filename=self.cert_file)