tags:

views:

6

answers:

1

WN servers have an alternative to cgi programs called filters. I have been trying to get one to work, but I have had no luck. I am writing in python. It looks like the server is not receiving any output from the program but is parsing nothing and wrapping this nothing in my standard header and footer. I have chmod 755 the program and my index.wn file reads:

Default-Attributes=parse
Default-Wrappers=templates/template1.inc

File=includeTests.html
File=index.html
File=archives.html
File=contact.html

File=style.css

File=testProgram.py

#here is the stuff about the filter
File=testFilter.html
Content-type=text/html
Filter=testProgram.py
Attributes=parse, cgi

here is what is in the filter called testProgram.py:


#!/usr/bin/python

print "Content-Type: text/html\n\n"
print "

hi

"

testProgram.py works perfectly if it is shoved into a cgi-bin folder and chmoded. I suppose my problem may lay with the fact that I have never ever seen a filter program in python. I'm not sure I have even seen a filter program at all. Does anyone out there have any experience with wn servers and filters? Any ideas?

A: 

I have no real-world WN experience, but I've read its docs and it seems to me there's something wrong with your code -- quoting,

no headers should be supplied by the program as WN will automatically provide them. For example, while a CGI/1.1 program typically starts with printing "Content-type: text/html" followed by a blank line, this should not be done for "someprogram" in the index.wn entry above, because WN will automatically provide the appropriate HTTP/1.1 headers based on the "Content-type=text/html" line in the index.wn file.

while you do seem to be supplying a header in your code. Second, you sure you want parsing, as you're requesting?

I don't see why either of these issues should just "swallow" your program's output, though, so this is hardly a complete answer... but maybe it could be a start.

BTW, since you say

I'm not sure I have even seen a filter program at all

the one example of filter I see in the docs is zcat -- at least this does make clear that a filter is a program that takes the given file as its standard input (but doesn't have to read it, the docs say... but that file, even if ignored as in your example code, must exist -- could that perhaps be the problem...?) and gives the contents (not headers) to send back on its standard output.

Alex Martelli