From: Kirk Haines Date: 2004-08-24T05:26:34+09:00 Subject: Re: Idea: Webshare On Tue, 24 Aug 2004 04:33:12 +0900, Patrick May wrote > The CGI object would provide the useful methods that make building > web apps easier. Each server would have a "CGD" that actually > provided the necessary common functionality. Different environments > may also have different ways of embedding the application, just like > you have iowa_fcgi.rb, iowa_webrick.rb, and mod_iowa.rb. I took what is essentially a lazy approach. I created a marshallable, incomplete copy of Apache::Request, basically, because it was familiar to me already. I then needed a way to populate it with all of the necessary data. I partitioned the world into two models: mod_ruby and not-mod-ruby- so-assume-CGI. The mod_ruby world makes it very easy to put all of the necessary data from the Apache::Request into my copy of Apache::Request. For the non-mod-ruby world, though, I simply assume that the standard CGI environment variables will be available, and I use those to fill out the request object. The nice thing about that model is that it then makes it trivial to make it work with any server that provides a CGI-like interface. All it really has to do is to create a request object, letting the object worry about the details of how to populate itself with the necessary data, and then send the object to the application, and it works for most things. My understanding is that IIS does not work like this, though, so I would need to do some work to get it to do the right thing with IIS. Overall, I like the model, though I am certain that it can be improved upon. So much code to write, and only two hands to do it with.... Anyway, I would think that for what you are talking about, you would probably do something somewhat similar in concept. Let me throw you a wrinkle to think about. File uploads. If you adopt a model where you are passing a request object to the webapp, and the webapp may not even be on the same machine as the webserver, what is the best way to handle uploaded files? You can't just create a tempfile like the current CGI does. Do you transfer the data with the request, but then write it to tempfiles on the other side? Does Drb provide a way that one could write the uploaded files to tempfiles on the server, but that one could access the tempfiles via the request object in the webapp? Could be cool. Might be a bad idea. Kirk Haines