spyce
home
license
community
download
examples
resources
wishlist
contrib (@sf)
documentation
intro
lang
runtime
modules
tags
install
exits
sourceforge
statistics
freshmeat

transparent transparent transparent
Examples
[[ Spyce ]]
Python Server Pages
by Rimon Barr

examples/error.spy
[[error.setFileHandler('error.spi') ]]
This is a page with an error...
[[ raise 'an error' ]]
Run this code.
(requires Spyce-enabled web server)

Supplemental files:

examples/error.spi
<h1>Oops</h1>
An error occurred while processing your request. 
We have logged this for our webmasters, and they 
will fix it shortly. We apologize for the inconvenience.
In the meantime, please use the parts of our site that 
actually do work... <a href="somewhere">somewhere</a>.
[[\
  # could redirect the user immediately
  #response.getModule('redirect').external('somewhere.spy')

  # could send an email
  import time
  msg = '''
time: %s
error: %s
env: %s
other info...
''' % (
    time.asctime(time.localtime(time.time())), 
    error.getString(),
    request.env()
  )
  #function_to_send_email('webmaster@foo.com', msg)

  #or perform other generic error handling...
]]

Back to List of Examples


© 2002 Rimon Barr
email: rimon AT acm DOT org
Spyce Powered SourceForge Logo [[ Spyce ]]
Python Server Pages
version 1.3.10