From tobia.conforto at linux.it Sat Jul 1 11:12:57 2006 From: tobia.conforto at linux.it (Toby) Date: Sat, 1 Jul 2006 13:12:57 +0200 Subject: [tbnl-devel] Re: Web programming question (was: Strange encoding problems...) In-Reply-To: <87lkre4312.fsf@localhost.localdomain> References: <87hd285vrp.fsf@localhost.localdomain> <87lkre4312.fsf@localhost.localdomain> Message-ID: <20060701111257.GG6313@localhost.localdomain> Dan Beauchesne wrote: > I've got a list of plists which I would like to use to generate a page > of clickable links (one link for each plist) which, when clicked, > would evaluate a lisp expression (actually, I just want to push that > plist entry onto another list). This isn't a Lisp or TBNL question, as much as a web programming one. If the main list of plists isn't mutating, you can tag each link with an index into the main list (/put?entry=23), so that the receiving function (the one handling "/put") knows what to do: (push (nth (get-parameter "entry") *main-list*) *other-list*) Otherwise, if the main list is mutating all the time, one way to do it is: 1. make a (shallow? deep?) copy of the main list; 2. use the copy to generate the links; 3. store the copy in a session variable; 4. use the session variable in the receiving handler. Remember to use locks (such as KMRCL's make-lock and with-lock-held) if the users can modify any global variable, otherwise chaos WILL ensue. (TBNL gurus correct me if I'm wrong) Toby -- Signed/encrypted mail welcome. GPG/PGP Key-Id: 0x15C5C2EA From edi at agharta.de Sun Jul 2 20:43:27 2006 From: edi at agharta.de (Edi Weitz) Date: Sun, 02 Jul 2006 22:43:27 +0200 Subject: [tbnl-devel] Re: Web programming question In-Reply-To: <20060701111257.GG6313@localhost.localdomain> (Toby's message of "Sat, 1 Jul 2006 13:12:57 +0200") References: <87hd285vrp.fsf@localhost.localdomain> <87lkre4312.fsf@localhost.localdomain> <20060701111257.GG6313@localhost.localdomain> Message-ID: On Sat, 1 Jul 2006 13:12:57 +0200, Toby wrote: > Otherwise, if the main list is mutating all the time, one way to do > it is: 1. make a (shallow? deep?) copy of the main list; 2. use the > copy to generate the links; 3. store the copy in a session variable; > 4. use the session variable in the receiving handler. Doing this with sessions is a good idea IMHO. I've done something similar myself several times. You can even create something like "private" (encoded) links which translate to arbitrary Lisp code and keep a table which translates from URLs to the corresponding actions in your session. From dbeauchesne at gmail.com Wed Jul 5 03:28:10 2006 From: dbeauchesne at gmail.com (Dan Beauchesne) Date: 05 Jul 2006 12:28:10 +0900 Subject: [tbnl-devel] Re: Web programming question In-Reply-To: References: <87hd285vrp.fsf@localhost.localdomain> <87lkre4312.fsf@localhost.localdomain> <20060701111257.GG6313@localhost.localdomain> Message-ID: <871wt091dh.fsf@localhost.localdomain> On 7/3/06, Edi Weitz wrote: > On Sat, 1 Jul 2006 13:12:57 +0200, Toby wrote: > > > Otherwise, if the main list is mutating all the time, one way to do > > it is: 1. make a (shallow? deep?) copy of the main list; 2. use the > > copy to generate the links; 3. store the copy in a session variable; > > 4. use the session variable in the receiving handler. > > Doing this with sessions is a good idea IMHO. I've done something > similar myself several times. You can even create something like > "private" (encoded) links which translate to arbitrary Lisp code and > keep a table which translates from URLs to the corresponding actions > in your session. Cool, thanks for the great ideas. Also, in regards to the UTF-8 + SBCL + content-length problem, I'm curious if Dr. Weitz's Lisp (Allegro?) does not have this problem? I've been looking for a good excuse to grab the student edition, maybe this is it :) Thanks again, -- Dan Beauchesne dbeauchesne -at- gmail -dot- com From edi at agharta.de Wed Jul 5 13:59:46 2006 From: edi at agharta.de (Edi Weitz) Date: Wed, 05 Jul 2006 15:59:46 +0200 Subject: [tbnl-devel] Re: Web programming question In-Reply-To: <871wt091dh.fsf@localhost.localdomain> (Dan Beauchesne's message of "05 Jul 2006 12:28:10 +0900") References: <87hd285vrp.fsf@localhost.localdomain> <87lkre4312.fsf@localhost.localdomain> <20060701111257.GG6313@localhost.localdomain> <871wt091dh.fsf@localhost.localdomain> Message-ID: On 05 Jul 2006 12:28:10 +0900, Dan Beauchesne wrote: > Also, in regards to the UTF-8 + SBCL + content-length problem, I'm > curious if Dr. Weitz's Lisp (Allegro?) does not have this problem? > I've been looking for a good excuse to grab the student edition, > maybe this is it :) I'm not using AllegroCL, I use LispWorks. The problem is actually always the same - the HTTP standard demands that the content length header counts the number of octets, but in Common Lisp, LENGTH applied to a string counts the number of characters which is not the same for UTF-8. The test/ directory of TBNL contains two example pages that deliver UTF-8 content. One is LW-only but it should be easy to convert it to SBCL using SBCL's internal STRING-TO-OCTETS function (see util.lisp), the other one uses TBNL:SEND-HEADERS and thus avoids to send a content length header at all. If your front-end is able to do that (like Apache/mod_lisp or Hunchentoot), then this should result in chunked encoding. HTH, Edi. From edi at agharta.de Wed Jul 5 14:09:29 2006 From: edi at agharta.de (Edi Weitz) Date: Wed, 05 Jul 2006 16:09:29 +0200 Subject: [tbnl-devel] Re: Web programming question In-Reply-To: (Edi Weitz's message of "Wed, 05 Jul 2006 15:59:46 +0200") References: <87hd285vrp.fsf@localhost.localdomain> <87lkre4312.fsf@localhost.localdomain> <20060701111257.GG6313@localhost.localdomain> <871wt091dh.fsf@localhost.localdomain> Message-ID: On Wed, 05 Jul 2006 15:59:46 +0200, Edi Weitz wrote: > using SBCL's internal STRING-TO-OCTETS function That should read "TBNL's internal ..." - I think the name of the function is the same in SBCL but it's external there. From edi at agharta.de Thu Jul 6 08:32:49 2006 From: edi at agharta.de (Edi Weitz) Date: Thu, 06 Jul 2006 10:32:49 +0200 Subject: [tbnl-devel] Re: Quick Question about Dispatch Handlers in TBNL In-Reply-To: <20060706035508.GA27632@setzer.hsd1.tx.comcast.net> (Cameron Desautels's message of "Wed, 5 Jul 2006 22:55:08 -0500") References: <20060706035508.GA27632@setzer.hsd1.tx.comcast.net> Message-ID: Hi! Please use the mailing list for questions about TBNL. On Wed, 5 Jul 2006 22:55:08 -0500, Cameron Desautels wrote: > I have a quick question about TBNL that I am hoping you wouldn't > mind helping me with. > > I'm a little surprised to see that TBNL does not contain a function > which creates a dispatcher that matches an exact string (rather than > a prefix or a regexp). Perhaps something like this?: > > (defun create-static-dispatcher (str page-function) > "A convenience function which will return a dispatch function > which will return `page-function' whenever the path portion of > the URI matches the string `str'." > (lambda (request) > (if (string= (script-name request) str) > page-function))) > > I'm somewhat curious what the reason for this omission is. Is it > because the same functionality can be achieved with > create-regex-dispatcher given a string with no wildcards? Certainly > that method would be less efficient and isn't as (logically) clear. > Am I missing something? > > Your enlightening reply is appreciated. I've never needed such a function, but as you demonstrate above it is trivial to build it yourself. I could add it to the next release if people feel that it's a worthwhile contribution. Concerning your remark about efficiency: Do you really think that the speed difference between a regex scan and a string comparison (if there is one) would be noticable in a web application? Cheers, Edi. From quasilists at gmail.com Thu Jul 6 10:14:20 2006 From: quasilists at gmail.com (quasi) Date: Thu, 06 Jul 2006 15:44:20 +0530 Subject: [tbnl-devel] customisation Message-ID: <871wszavlv.fsf@agni4.cltp.com> Hey, I have deployed a lisp web site app. :) It runs pretty nicely. I am using CMUCL 19c and TBNL 0.9.10. Some of the dynamic pages service 45pages/sec at concurrency of 1000 (ab benchmark). thanks Edi for TBNL and the CMUCL folks for CMUCL. I need now to customize some things. I need to desperately get rid of the Internal Server Error page. If someone types in a url part of which triggers a prefix dispatcher then we get this simple "Internal Server Error" page with a info string at the bottom. I need to change both of these. Any pointers on how to do these things? I redefined the tbnl::tbnl-info-string in my source. Now I get my output string AND the original tbnl string. thanks, -- quasi Utopia Unlimited! From edi at agharta.de Thu Jul 6 12:58:02 2006 From: edi at agharta.de (Edi Weitz) Date: Thu, 06 Jul 2006 14:58:02 +0200 Subject: [tbnl-devel] customisation In-Reply-To: <871wszavlv.fsf@agni4.cltp.com> (quasi's message of "Thu, 06 Jul 2006 15:44:20 +0530") References: <871wszavlv.fsf@agni4.cltp.com> Message-ID: Hi! On Thu, 06 Jul 2006 15:44:20 +0530, quasi wrote: > I need to desperately get rid of the Internal Server Error page. If > someone types in a url part of which triggers a prefix dispatcher > then we get this simple "Internal Server Error" page with a info > string at the bottom. The dispatcher triggers an error? I can't believe that. I'm pretty sure the error happens in your handler somewhere. Have you tried to debug this? http://weitz.de/tbnl/#*show-lisp-errors-p* http://weitz.de/tbnl/#*show-lisp-backtraces-p* > I need to change both of these. > > Any pointers on how to do these things? http://weitz.de/tbnl/#*http-error-handler* > I redefined the tbnl::tbnl-info-string in my source. Now I get my > output string AND the original tbnl string. Generally, you shouldn't cope with things that aren't exported unless you absolutely know what you're doing. HTH, Edi. From quasilists at gmail.com Fri Jul 7 16:37:51 2006 From: quasilists at gmail.com (quasi) Date: Fri, 07 Jul 2006 22:07:51 +0530 Subject: [tbnl-devel] customisation In-Reply-To: (Edi Weitz's message of "Thu, 06 Jul 2006 14:58:02 +0200") References: <871wszavlv.fsf@agni4.cltp.com> Message-ID: <87k66pjrq8.fsf@agni4.cltp.com> On 6 Jul 2006, Edi Weitz spake thusly: > Hi! > > On Thu, 06 Jul 2006 15:44:20 +0530, quasi wrote: > >> I need to desperately get rid of the Internal Server Error page. >> If someone types in a url part of which triggers a prefix >> dispatcher then we get this simple "Internal Server Error" page >> with a info string at the bottom. > > The dispatcher triggers an error? I can't believe that. I'm pretty > sure the error happens in your handler somewhere. Have you tried to > debug this? ooops! I was meaning the handler. I needed to see why it was screwing up. :) Thanks for the pointer. Invaluable. I need to read the docs more seriously. > > http://weitz.de/tbnl/#*show-lisp-errors-p* > http://weitz.de/tbnl/#*show-lisp-backtraces-p* > > > http://weitz.de/tbnl/#*http-error-handler* :) Solved all my problems absolutely. Thanks a mill. www.cleartrip.com is the website. index, flight search and hotel search pages come via TBNL+CMUCL. The search is done by a backend java app which is a bit shaky. They are working on it. > Generally, you shouldn't cope with things that aren't exported > unless you absolutely know what you're doing. yup. -- quasi Utopia Unlimited!