Basically, I think all your problems go away in v1.1.41. That's what I'm
hoping... But let's dive into the details.
>i'm writing my module and i'm getting a strange behavior that i can't
>explain: my module have several methods which, in case of a problem (bad
>authentication) should return a 401 Unauthorized code and stop further
>processing. I discovered that using any method of
>spyce.spyceResponsethrows a 'not implemented' exception, so use of
>self.response is forbidden. I then got a reference to the response module
>through the use of the getModule() method. I use it this way:
Thank you for the code sample! It helped a lot. I changed it as follows,
just to get it to run. (Nothing significant).
By the way, you now have all the HTTP status codes as constants in
spyce.py. 401 = spyceResponse.RETURN_UNAUTHORIZED.
from spyceModule import spyceModule
self.response_module = self.getModule('response')
It's basically what you have. I then ran:
telnet localhost 80
GET /tmp/rim.spy HTTP/1.0
HTTP/1.1 401 Authorization Required
Date: Fri, 06 Sep 2002 01:00:09 GMT
Server: Apache/1.3.22 (Unix) (Red-Hat/Linux) mod_fastcgi/2.2.12
X-Spyce: Spyce/1.1.41 Python/1.5
Connection closed by foreign host.
I think this is what you wanted, no? Well, I checked it under Spyce
v1.1.41, under both mod_python and mod_fastcgi running on Linux. (BTW, I
made some radical modifications to the engine since v1.1.40, to simplify
some special case code that was causing problems... The problems, I think,
were with the status codes, and the problem was particularly pronounced
under the mod_python configuration - I hadn't tested that for a while.
Please check and see if your problem has gone away.)
>where auth.set() should return a 401 code (by the use of
>setReturnCode()). on the output, i got a 200 return code, then the output
>of all the script excluding the output of auth.set(), then the output of
>auth.set(), that is a HTTP header with the 401 return code, and the
>content of my custom error page (setted up with the ErrorDocument
>directive in the server conf).
Yes, this has been fixed in v1.1.41. You were probably running under
mod_python. This was the one configuration that had a problem.
>btw, i noticed just now that the use of the cookie module
>(getModule('cookie')) outputs on the main request.
>i tried to write:
> raise spyce.spyceDone
>but then i got the 200 return code, then the output of auth.set(), that is a
>HTTP header with the 401 return code, and the content of my custom error
>page. (but this time, nothing from the script)
Yes, that was a related bug. Lots of 'special case' code that has now been
cleaned up. Please re-test. I think I have addressed all of this.
Plus, in the current release you have the long-awaited error-handling
>ps: i'm sorry if my explanations are not clear at all, but i'm a bit sick
>tonight and fever does not help explaining things. if you need clearer
>explanations, please let me know.
Your examples helped a lot. Thank you. In future, please also tell me
something about the configuration that you are running. I usually run with
mod_fastcgi, so it took me a while to replicate your error. I had to
switch to mod_python. For example, "I am running Spyce v1.1.41, under
mod_python and Linux using Python v1.5.2". That should be enough
information for most problems.
Sidenote: I remember that you mentioned (in some email) that you had
trouble using spyce.spyceResponse methods in your functions... You never
use spyce.spyceResponse directly. The self.response inside any module is a
SUB-CLASS of spyce.spyceResponse, and all those method have
implementations - they no longer raise 'not implemented' exceptions.
All the best,
PS - I am looking forward to seeing your auth module. It's something that
I think will be (or can be adapted to be) of general use.
* Rimon Barr Ph.D. candidate, Computer Science, Cornell University
| barr@... - http://www.cs.cornell.edu/barr - Y!IM: batripler
| Understanding is a kind of ecstasy.
+---- -- Carl Sagan