Documentation - Runtime
The Spyce file is executed top-down, until the end of the file is reached, a
valued is returned, or an exception is thrown,
whichever comes first. If the code terminates via an unhandled exception, then
it is caught by the Spyce engine. Depending on the exception type, different
actions are taken:
- spyceDone can be raised at any time to stop the Spyce processing
(without error) at that point. It is often used to stop further output, as
in the example below that emits a binary image file. The spyceDone
exception, however, is more useful for modules writers. In regular Spyce
code one could simply issue a return statement,
with the same effect.
- spyceRedirect is used by the
redirect module. It causes the
Spyce engine to immediately redirect the request to another Spyce file
internally. Internally means that we do not send back a redirect to
the browser, but merely clear the output buffer and start processing a new
- All other exceptions that occur at runtime will be processed via
the Spyce error module. This
module will emit a default error message, unless the user has installed some
other error handler.
Note that non-runtime exceptions, such as exceptions caused by compile errors,
missing files, access restrictions and the like, are handled by the server.
The default server error handler
can be configured via the server configuration file.
[[.import name=include ]]
# Spyce can also generate other content types
# The following code displays the Spyce logo
import os.path, spyce
path = os.path.join(spyce.getServer().config.SPYCE_HOME, 'www', 'spyce.gif')
Run this code