From: Dave Thomas Date: 2003-07-28T00:14:37+09:00 Subject: Re: Web tools for mod_ruby - Dave Thomas Carl Youngblood wrote: > I have been a PHP coder for a long time now and while its OO environment not > nearly as pristine as Ruby's, the convenient functionality that it makes > available to web programmers and its high performance is tipping the scale > in its favor for web development. But I'm really interested in branching > out and trying web development on Ruby. However, these types of tools make > an enormous difference. Right now, mod_ruby appears to be very much in its > infancy with little activity on the modruby.net web site. One of the constraints imposed by my clients is that I couldn't use cookies, so I implemented sessions using URL rewriting. This wasn't really anything to do with mod_ruby; it was just some stuff in my code. Whenever I needed a link or button on a page that was supposed to call back to my page, I invoked a method { "ok" => url(:handle_ok), "help" => url(:handle_help, "register", user_details), } This method did two things. It saved the name of the method to be called, along with any parameters, in a dispatch table. It then generated a unique number which encoded a session ID and the index into that dispatch table. This is the URL given to the browser. Then, just before my code finished handling the original request, it persisted the current session (which includes the dispatch table) as a serialized object into a row in a database table. When the user clicks on one ofthe links, control comes back to my code. I decode the URL to get the session key, then use it to read in the row from the table. I deserialize that, then reconstitute all by session data and the original dispatch table. I then decode the index in that table out of the URL, and invoke the appropriate method using any parameters that were perviously saved. I'm afraid I can't post the code: it's currently commercial. However, it isn't big: 2-300 lines at most. Cheers Dave