Currently, I use "raise spyceDone" within a .spy file
to terminate processing of the file (for example, on a
complex page which requires user authentication-- if
the user isn't permitted to do anything then it's best
not to process the entire page, merely, "you don't have
access" followed by "raise spyceDone".
This works great, however, I sometimes include (.spi)
files which I might use for authentication as opposed
to doing it inline. If I raise spyceDone in these .spi
files, it apparently returns control to the parent
(.spy file), however, the .spy file continues to be
processed as normal (I couldn't get the spyceDone to
automatically propagate up from the .spy file. What
this forces me to do is this:
.spy file:
[[\
try:
include('auth.spi']
except:
raise spyceDone
]]
.spi file:
# user doesn't have permission
raise Exception
What I'd prefer is this:
.spy file:
[[include('auth.spi')]]
.spi file:
# user doesn't have permission
raise spyceDone # or a different Spyce Exception
In the latter example, if the .spi file raises the
spyceDone exception, then the .spy file should
propagate the exception. Currently, this is not the
behavior. If doing so doesn't jive with the Spyce
philosophy of spyceDone, then perhaps a new,
spyceFinalize, spyceComplete, spyceReallyDone or
similar exception could be used to serve this pupose.
That is, if a spyceFinalize was raised in a .spi file,
then the .spy file should raise a spyceDone (or
propagate the spyceFinalized exception) at this point
such that no further processing is done in the .spy
file. Having such a facility could streamline a .spy
file into a series of includes, without any manual
exception handling, if the coder so desires.
Logged In: YES
user_id=371556
Correct, an exception should propagate to the top of the
stack through all frames (method call, include, spylambda,
etc.), unless stopped by a catch. This is exactly what was
intended for spyceDone, and its semantics have now been
fixed. If one wants the old, broken spyceDone behaviour then
the include can be wrapped in a try/catch.
Logged In: YES
user_id=657828
Originator: NO
this will be in Spyce 2.2; raise spyceEnd to stop all execution, and spyceEndLocal to stop the current include.