Paul D wrote: > Hi! > Long time lurker, first time poster. > > I'm writing a web application that: > "backend" > Every three minutes parses a webpage and checks for problems (server > monitoring). After that it matches those against a ruleset (SQLObject > and pySQLite) to weed out unimportant problems. > > webui > The web UI will reload a frame every 30 seconds to check for new > problems and play an alarm there are any. The problem will be assigned > to the user who first clicks on it, the user will either solve it and > write down the solution, or create a new rule to ignore it in the future. > > Right now I got the "backend" kind of working. The problem is how to > glue these parts together. I'm using medusa and I'd like to just one > process - running the 'backend' as a thread. The server has to be able > to run on winnt as a service. There won't be many users (max 15 > concurrent). Another thing is that the update/rulematching takes about > 10-30 seconds and it's gonna be a mess if the webui checks for problems > within an update, I'll need some kind of locking mechanism. > I've come up with two solutions: > The NT service part shouldn't be a problem. Do you need sample code? > 1. Start the backend as a thread in the quixote __init__py file. The > webui will check a dictionary with problems in the backend every minute. > Since I'm using medusa the thread will only be started once but it's not > very pretty. > If you take this approach, read the recent postings on double-imports to be sure you don't inadvertently start more than one thread! > 2. Start the backend within the medusa_server.py script. I can't figure > out a way to get the webui to have access to the backend namespace this > way. Maybe subclass the Publisher and pass a reference to the backend in > the request object? Personally, I would prefer this over the implicit start-thread-on-module-import approach. Subclassing Publisher.start_request() is easy and effective. > Another solution is to make the backend write problems to a database > table and have the webui check this table every minute. > You could also run the backend as a separate process/service, and have your Web app talk to it via the database, or by some other protocol. Your backend and UI services could share a common business-object package. If your backend may have clients other than the Web app, this might be a sensible approach. > Oh, another question: is it possible to raise an exception i the thread > and have quixote exception tools handle it and present it when the user > eventually fetches another page? > You could always store your exception reports in the database; then they are just data, and the web UI could have a facet for viewing these repots. > What's the best solution? I'm pretty new to python and designing bigger > things then filename sorters so any input is interesting. > > thanks! / Paul Best of luck! -- Graham