I am trying to use my own debugging/logging system and I am getting something
strange in forms. Here is my driver script:
#!/usr/local/bin/python
import sys
from quixote import Publisher
sys.path.append("/home/micheles/md/python/quixote")
app = Publisher('simpleform')
app.publish_cgi()
Notice that I am NOT calling setup_logs.
Here is the script I am debugging:
_q_exports = ["form_demo"]
import sys
from quixote.form import Form
sys.stderr = sys.stdout = file("/tmp/x.log", "a")
print "hello from main"
class FormDemo(Form):
def __init__(self):
Form.__init__(self)
self.add_widget("checkbox", "confirm", title="Are you sure?")
self.add_submit_button("submit", "submit")
def action (self, request, submit_button, form_data):
print "hello from form"
return "ok"
def form_demo(request):
return FormDemo().handle(request)
If I run the script my log file contains the following two lines:
$ cat /tmp/x.log
hello from main
hello from main
(the first line is written when the form is displayed, the second after the form
is submitted). I do NOT see a line "hello from form" so I guess inside the
form sys.stdout is redirected somewhere else. How is that? Can I change
this behavior? If not, I will just use "print >> logfile", but I
curious to understand
what is happening.
Michele Simionato