Hmmm...
Medusa (by default) logs all accesses to stdout. If you set things up in
the 'normal' way, it'll store a reference to stdout before Quixote has
replaced that with the debug log file. This is desirable; if this didn't
happen, your debug log would also have all your access logging information.
Simply doing the publisher.setup_logs() before instantiating the http_server
would probably get you up and running, but your debug log would turn into
your access log + debug log. There are two ways around this, that I can
think of at the moment.
1) Let Quixote handle access logging. Set up the access log parameter in
the quixote conf file, and pass a dummy logger to the
http_server.http_server(). If you do this, make sure you've applied my
recent patch to make sure Qx logs ALL requests. .7a3 (unpatched) will only
log *successful* requests.
2) (This will probably be easier) Pass a logger to the
http_server.http_server() call which will be used for logging.
In more detail: In your driver script, you probably have a line like:
server = http_server.http_server('', port)
or something like that.
What you'll need is something like this:
from medusa import logger
logObject = logger.file_logger('/some/path/to/my/access/log/file.log')
server = http_server.http_server('', port, logger_object=logObject)
This will tell medusa where to log, rather than just letting it hook into
stdout.
I think either one of those will get you up and running...
Jason
-----Original Message-----
From: quixote-users-bounces+jsibre=chironsys.com@mems-exchange.org
[mailto:quixote-users-bounces+jsibre=chironsys.com@mems-exchange.org]On
Behalf Of Samir Patel
Sent: Sunday, March 28, 2004 11:36 PM
To: quixote-users@mems-exchange.org
Subject: [Quixote-users] Re: Need help in running quixote.demo as
medusas'ortwisteds' win32 service
Jason,
Thanks for you suggestion about config file to redirect output. It help
somewhat. I can run quixote.demo as a medusa service. Still there is one big
problem: When form or widget is submitted, it does nothing. Here is my new
program:
*****************************************************************
import win32serviceutil
import win32service
import win32event
class motorService(win32serviceutil.ServiceFramework):
_svc_name_ = "motorService"
_svc_display_name_ = "Motor Service"
def __init__(self, args):
win32serviceutil.ServiceFramework.__init__(self, args)
self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)
def SvcStop(self):
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
win32event.SetEvent(self.hWaitStop)
def SvcDoRun(self):
import asyncore
from quixote.server.medusa_http import http_server, QuixoteHandler
from quixote import enable_ptl
from quixote.publish import Publisher
enable_ptl()
server = http_server.http_server('', 80)
publisher = Publisher('quixote.demo')
publisher.read_config("c:/demo.conf")
publisher.setup_logs()
dh = QuixoteHandler(publisher, 'quixote/demo', server)
server.install_handler(dh)
asyncore.loop()
win32event.WaitForSingleObject(self.hWaitStop,
win32event.INFINITE)
if __name__=='__main__':
win32serviceutil.HandleCommandLine(motorService)
************************************************************
with demo.conf file:
DEBUG_LOG = "c:/quixote-demo-debug.log"
ERROR_LOG = "c:/quixote-demo-error.log"
DISPLAY_EXCEPTIONS = "plain"
SECURE_ERRORS = 0
*********************************************
and c:\quixote-demo-debug.log file:
debug message from the index page
error: Server Error: exceptions.IOError, [Errno 9] Bad file descriptor:
file: c:\python23\Lib\site-packages\medusa\logger.py line: 64
error: uncaptured python exception, closing channel
(exceptions.IOError:[Errno 9] Bad file descriptor
[C:\Python23\lib\asyncore.py|write|77]
[C:\Python23\lib\asyncore.py|handle_write_event|397]
[C:\Python23\lib\asynchat.py|handle_write|152]
[C:\Python23\lib\asynchat.py|initiate_send|213]
[C:\Python23\lib\asynchat.py|refill_buffer|200]
[c:\python23\Lib\site-packages\medusa\producers.py|more|179]
[c:\python23\Lib\site-packages\medusa\producers.py|more|206]
[c:\python23\Lib\site-packages\medusa\http_server.py|log|283]
[c:\python23\Lib\site-packages\medusa\logger.py|log|242]
[c:\python23\Lib\site-packages\medusa\logger.py|log|76]
[c:\python23\Lib\site-packages\medusa\logger.py|write|52]
[c:\python23\Lib\site-packages\medusa\logger.py|maybe_flush|64])
error: Server Error: exceptions.IOError, [Errno 9] Bad file descriptor:
file: c:\python23\Lib\site-packages\medusa\logger.py line: 64
error: uncaptured python exception, closing channel
(exceptions.IOError:[Errno 9] Bad file descriptor
[C:\Python23\lib\asyncore.py|write|77]
[C:\Python23\lib\asyncore.py|handle_write_event|397]
[C:\Python23\lib\asynchat.py|handle_write|152]
[C:\Python23\lib\asynchat.py|initiate_send|213]
[C:\Python23\lib\asynchat.py|refill_buffer|200]
[c:\python23\Lib\site-packages\medusa\producers.py|more|179]
[c:\python23\Lib\site-packages\medusa\producers.py|more|206]
[c:\python23\Lib\site-packages\medusa\http_server.py|log|283]
[c:\python23\Lib\site-packages\medusa\logger.py|log|242]
[c:\python23\Lib\site-packages\medusa\logger.py|log|76]
[c:\python23\Lib\site-packages\medusa\logger.py|write|52]
[c:\python23\Lib\site-packages\medusa\logger.py|maybe_flush|64])
error: uncaptured python exception, closing channel
(exceptions.IOError:[Errno 9] Bad file descriptor
[C:\Python23\lib\asyncore.py|read|69]
[C:\Python23\lib\asyncore.py|handle_read_event|390]
[C:\Python23\lib\asynchat.py|handle_read|118]
[c:\python23\Lib\site-packages\medusa\http_server.py|found_terminator|448]
[c:\python23\Lib\site-packages\medusa\http_server.py|found_terminator|150]
[c:\python23\Lib\site-packages\medusa\xmlrpc_handler.py|found_terminator|87]
[c:\python23\Lib\site-packages\quixote\server\medusa_http.py|continue_reques
t|128] [c:\python23\Lib\site-packages\medusa\http_server.py|done|250]
[C:\Python23\lib\asynchat.py|push_with_producer|163]
[C:\Python23\lib\asynchat.py|initiate_send|213]
[C:\Python23\lib\asynchat.py|refill_buffer|200]
[c:\python23\Lib\site-packages\medusa\producers.py|more|179]
[c:\python23\Lib\site-packages\medusa\producers.py|more|206]
[c:\python23\Lib\site-packages\medusa\http_server.py|log|283]
[c:\python23\Lib\site-packages\medusa\logger.py|log|242]
[c:\python23\Lib\site-packages\medusa\logger.py|log|76]
[c:\python23\Lib\site-packages\medusa\logger.py|write|52]
[c:\python23\Lib\site-packages\medusa\logger.py|maybe_flush|64])
error: Server Error: exceptions.IOError, [Errno 9] Bad file descriptor:
file: c:\python23\Lib\site-packages\medusa\logger.py line: 64
error: uncaptured python exception, closing channel
(exceptions.IOError:[Errno 9] Bad file descriptor
[C:\Python23\lib\asyncore.py|write|77]
[C:\Python23\lib\asyncore.py|handle_write_event|397]
[C:\Python23\lib\asynchat.py|handle_write|152]
[C:\Python23\lib\asynchat.py|initiate_send|213]
[C:\Python23\lib\asynchat.py|refill_buffer|200]
[c:\python23\Lib\site-packages\medusa\producers.py|more|179]
[c:\python23\Lib\site-packages\medusa\producers.py|more|206]
[c:\python23\Lib\site-packages\medusa\http_server.py|log|283]
[c:\python23\Lib\site-packages\medusa\logger.py|log|242]
[c:\python23\Lib\site-packages\medusa\logger.py|log|76]
[c:\python23\Lib\site-packages\medusa\logger.py|write|52]
[c:\python23\Lib\site-packages\medusa\logger.py|maybe_flush|64])
error: uncaptured python exception, closing channel
(exceptions.IOError:[Errno 9] Bad file descriptor
[C:\Python23\lib\asyncore.py|read|69]
[C:\Python23\lib\asyncore.py|handle_read_event|390]
[C:\Python23\lib\asynchat.py|handle_read|118]
[c:\python23\Lib\site-packages\medusa\http_server.py|found_terminator|448]
[c:\python23\Lib\site-packages\medusa\http_server.py|found_terminator|150]
[c:\python23\Lib\site-packages\medusa\xmlrpc_handler.py|found_terminator|87]
[c:\python23\Lib\site-packages\quixote\server\medusa_http.py|continue_reques
t|128] [c:\python23\Lib\site-packages\medusa\http_server.py|done|250]
[C:\Python23\lib\asynchat.py|push_with_producer|163]
[C:\Python23\lib\asynchat.py|initiate_send|213]
[C:\Python23\lib\asynchat.py|refill_buffer|200]
[c:\python23\Lib\site-packages\medusa\producers.py|more|179]
[c:\python23\Lib\site-packages\medusa\producers.py|more|206]
[c:\python23\Lib\site-packages\medusa\http_server.py|log|283]
[c:\python23\Lib\site-packages\medusa\logger.py|log|242]
[c:\python23\Lib\site-packages\medusa\logger.py|log|76]
[c:\python23\Lib\site-packages\medusa\logger.py|write|52]
[c:\python23\Lib\site-packages\medusa\logger.py|maybe_flush|64])
error: Server Error: exceptions.IOError, [Errno 9] Bad file descriptor:
file: c:\python23\Lib\site-packages\medusa\logger.py line: 64
error: uncaptured python exception, closing channel
(exceptions.IOError:[Errno 9] Bad file descriptor
[C:\Python23\lib\asyncore.py|write|77]
[C:\Python23\lib\asyncore.py|handle_write_event|397]
[C:\Python23\lib\asynchat.py|handle_write|152]
[C:\Python23\lib\asynchat.py|initiate_send|213]
[C:\Python23\lib\asynchat.py|refill_buffer|200]
[c:\python23\Lib\site-packages\medusa\producers.py|more|179]
[c:\python23\Lib\site-packages\medusa\producers.py|more|206]
[c:\python23\Lib\site-packages\medusa\http_server.py|log|283]
[c:\python23\Lib\site-packages\medusa\logger.py|log|242]
[c:\python23\Lib\site-packages\medusa\logger.py|log|76]
[c:\python23\Lib\site-packages\medusa\logger.py|write|52]
[c:\python23\Lib\site-packages\medusa\logger.py|maybe_flush|64])
error: Server Error: exceptions.IOError, [Errno 9] Bad file descriptor:
file: c:\python23\Lib\site-packages\medusa\logger.py line: 64
error: uncaptured python exception, closing channel
(exceptions.IOError:[Errno 9] Bad file descriptor
[C:\Python23\lib\asyncore.py|write|77]
[C:\Python23\lib\asyncore.py|handle_write_event|397]
[C:\Python23\lib\asynchat.py|handle_write|152]
[C:\Python23\lib\asynchat.py|initiate_send|213]
[C:\Python23\lib\asynchat.py|refill_buffer|200]
[c:\python23\Lib\site-packages\medusa\producers.py|more|179]
[c:\python23\Lib\site-packages\medusa\producers.py|more|206]
[c:\python23\Lib\site-packages\medusa\http_server.py|log|283]
[c:\python23\Lib\site-packages\medusa\logger.py|log|242]
[c:\python23\Lib\site-packages\medusa\logger.py|log|76]
[c:\python23\Lib\site-packages\medusa\logger.py|write|52]
[c:\python23\Lib\site-packages\medusa\logger.py|maybe_flush|64])
error: Server Error: exceptions.IOError, [Errno 9] Bad file descriptor:
file: c:\python23\Lib\site-packages\medusa\logger.py line: 64