On 17 Mar 2001, David N. Welton wrote:
> Michael Link <[EMAIL PROTECTED]> writes: > > > > Tcl_CreateObjCommand(interp, "r", cmd_r, NULL, NULL); > > > > 'request_rec' might be more descriptive. Is there a problem with > > > putting all these commands in a namespace of their own, like > > > 'Apache::' (to borrow something from the perl folks)? > > > hmm, I suppose I could do this, I thought mod_perl also used a > > convention like `r'? > > Leggibility isn't always that important for the perl folks, either;-) > > If it were used with the namespace, ::apache::r, it would be easy to > pick out, but I worry about grepping through code trying to find an > 'r' somewhere (if it has been imported, for instance, into the current > namespace). it is in ::apache::r but your right, the first thing I did was import ::apache > > > The reason I used r is because it is customary for the request_rec > > variable passed to handlers to be called r. So if your writing > > modules you always see statements like this `r->server_name'. I > > thought it would be an easier transfer of knowledge if someone knew > > how to deal with C modules. > > This makes sense... but more so for the command names, I think. hmm, how about I offer the option to use request_rec or r? > > > This is the same thought applied to the command names for the > > functions, they are all synonomous with the apache function name > > ap_*. Let me know what you think. As far as putting them in a > > namespace, I don't see why this can't be done. > > Another thing... > > I haven't looked at it in detail yet, and haven't tried running > things, either, but could you explain a bit about your thoughts behind > the execution model? It runs a file in a namespace using the filename > itself for the namespace name? Here is what happens. 0. The server starts up, the interp is initialized etc. 1. A request for file /index.tm is requested. The file is looked up to see if it is already in the interp. If the file is not there (or the modification date has changed) the file is loaded into the interp as a script (since everything should be a proc). The file is loaded into a namespace with the name of the file. This is done because someone usually has a general config directive like this Tcl_ContentHandler content_handler which tells us that the proc we want to call for a content handler is named content_handler. If you have more than 1 file then you will need to use the name content_handler for all the files in that directory. Loading all these files into the global namespace will overwrite each others content_handler procedure with the last one read in. It could also rewrite other use defined functions... To avoid this every file is loaded into its own namespace. 2. The handler/hook is called, DECLINEd if not defined... Also pre Apache 2.0 I was defining variables like env and pram (form read data) into the global namespace. In 2.0 I have changed this so that env and pram are read into the namespace of the current file being requested because its possible that 2 simultaneous requests are made and if we were reading and writing global data that would be a problem, global should be protected with threads. Now I have no idea if its possible for Apache 2.0 to exec 2 handlers at the same time, I haven't checked into this yet, and I was assuming that it syncronized them itself, but thats a poor assumption on my part, and its on my list to check. Also I'm not sure what the concurrency of Apache 2.0 is set to either, its possible that they have it set so only 1 thread is active at 1 time, but this would be ineffecient, so I doubt it. -- > > Any thoughts about generalizing this out even further? > > Thanks, > -- > David N. Welton > Free Software: http://people.debian.org/~davidw/ > Apache Tcl: http://tcl.apache.org/ > Personal: http://www.efn.org/~davidw/ > Work: http://www.innominate.com/ >
