From patrick.may at mac.com Wed May 7 21:15:00 2014 From: patrick.may at mac.com (Patrick May) Date: Wed, 07 May 2014 17:15:00 -0400 Subject: [Tbnl-devel] [hunchentoot-devel] 404 page In-Reply-To: References: Message-ID: <7191141E-D10B-46FE-A8C4-2E6AD8171477@mac.com> Dredging up an old question?. On this machine I don?t have the code I used the last time I asked this question. I tried this: (defmethod acceptor-status-message ((acceptor (eql *test-acceptor*)) (http-status-code (eql 404))) (display-404-page)) but it doesn?t display my own 404 page. What Hunchentoot concept am I missing? Thanks, Patrick On May 31, 2012, at 3:24 PM, Hans H?bner wrote: > On Thu, May 31, 2012 at 8:12 PM, Patrick May wrote: > I'm sure I'm overlooking something simple in the documentation, but I've Googled madly and not found the answer. How do I specify my own 404 page in Hunchentoot? > > This is actually documented, albeit maybe a bit hard to find: http://weitz.de/hunchentoot/#acceptor-status-message - I'd gladly accept a documentation patch that puts some prose describing how to customize error pages into a separate chapter. > > With no further customization, the error page templates are located in the www/errors/ subdirectory of the Hunchentoot source distribution. > > Let me know if you have further questions. > > -Hans > > _______________________________________________ > tbnl-devel site list > tbnl-devel at common-lisp.net > http://common-lisp.net/mailman/listinfo/tbnl-devel -------------- next part -------------- An HTML attachment was scrubbed... URL: From hans.huebner at gmail.com Thu May 8 06:28:53 2014 From: hans.huebner at gmail.com (=?ISO-8859-1?Q?Hans_H=FCbner?=) Date: Thu, 8 May 2014 08:28:53 +0200 Subject: [Tbnl-devel] [hunchentoot-devel] 404 page In-Reply-To: <7191141E-D10B-46FE-A8C4-2E6AD8171477@mac.com> References: <7191141E-D10B-46FE-A8C4-2E6AD8171477@mac.com> Message-ID: Patrick, you cannot specialize a generic function on the run-time value of a variable. In your method definition, you are trying to specialize the ACCEPTOR argument on (EQL *TEST-ACCEPTOR*)), but *TEST-ACCEPTOR* in that definition will be evaluated at compile-time, not at run-time. Thus, you're probably specializing on NIL or some other random object. Is there any reason why you want to specialize on a particular instance rather than the class of the acceptor (or T)? -Hans 2014-05-07 23:15 GMT+02:00 Patrick May : > Dredging up an old question.... > > On this machine I don't have the code I used the last time I asked this > question. I tried this: > > (defmethod acceptor-status-message ((acceptor (eql *test-acceptor*)) > (http-status-code (eql 404))) > (display-404-page)) > > but it doesn't display my own 404 page. What Hunchentoot concept am I > missing? > > Thanks, > > Patrick > > > On May 31, 2012, at 3:24 PM, Hans H?bner wrote: > > On Thu, May 31, 2012 at 8:12 PM, Patrick May wrote: > I'm sure I'm overlooking something simple in the documentation, but > I've Googled madly and not found the answer. How do I specify my own 404 > page in Hunchentoot? > > This is actually documented, albeit maybe a bit hard to find: > http://weitz.de/hunchentoot/#acceptor-status-message - I'd gladly > accept a documentation patch that puts some prose describing how to > customize error pages into a separate chapter. > > With no further customization, the error page templates are located in the > www/errors/ subdirectory of the Hunchentoot source distribution. > > Let me know if you have further questions. > > -Hans > > _______________________________________________ > tbnl-devel site list > tbnl-devel at common-lisp.net > http://common-lisp.net/mailman/listinfo/tbnl-devel > > > > _______________________________________________ > Tbnl-devel mailing list > Tbnl-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/tbnl-devel > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From patrick.may at mac.com Thu May 8 13:07:53 2014 From: patrick.may at mac.com (Patrick May) Date: Thu, 08 May 2014 09:07:53 -0400 Subject: [Tbnl-devel] [hunchentoot-devel] 404 page In-Reply-To: References: <7191141E-D10B-46FE-A8C4-2E6AD8171477@mac.com> Message-ID: Hans, That would be ?debugging by public embarrassment? in action. ;-) Removing the incorrect eql specialization still doesn?t result in my 404 page being displayed. Do I have to subclass acceptor to get it to work? Thanks, Patrick On May 8, 2014, at 2:28 AM, Hans H?bner wrote: > Patrick, > > you cannot specialize a generic function on the run-time value of a variable. In your method definition, you are trying to specialize the ACCEPTOR argument on (EQL *TEST-ACCEPTOR*)), but *TEST-ACCEPTOR* in that definition will be evaluated at compile-time, not at run-time. Thus, you're probably specializing on NIL or some other random object. Is there any reason why you want to specialize on a particular instance rather than the class of the acceptor (or T)? > > -Hans > > > 2014-05-07 23:15 GMT+02:00 Patrick May : > Dredging up an old question?. > > On this machine I don?t have the code I used the last time I asked this question. I tried this: > > (defmethod acceptor-status-message ((acceptor (eql *test-acceptor*)) > (http-status-code (eql 404))) > (display-404-page)) > > but it doesn?t display my own 404 page. What Hunchentoot concept am I missing? > > Thanks, > > Patrick > > > On May 31, 2012, at 3:24 PM, Hans H?bner wrote: > >> On Thu, May 31, 2012 at 8:12 PM, Patrick May wrote: >> I'm sure I'm overlooking something simple in the documentation, but I've Googled madly and not found the answer. How do I specify my own 404 page in Hunchentoot? >> >> This is actually documented, albeit maybe a bit hard to find: http://weitz.de/hunchentoot/#acceptor-status-message - I'd gladly accept a documentation patch that puts some prose describing how to customize error pages into a separate chapter. >> >> With no further customization, the error page templates are located in the www/errors/ subdirectory of the Hunchentoot source distribution. >> >> Let me know if you have further questions. >> >> -Hans >> >> _______________________________________________ >> tbnl-devel site list >> tbnl-devel at common-lisp.net >> http://common-lisp.net/mailman/listinfo/tbnl-devel > > > _______________________________________________ > Tbnl-devel mailing list > Tbnl-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/tbnl-devel > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hans.huebner at gmail.com Thu May 8 13:12:50 2014 From: hans.huebner at gmail.com (=?ISO-8859-1?Q?Hans_H=FCbner?=) Date: Thu, 8 May 2014 15:12:50 +0200 Subject: [Tbnl-devel] [hunchentoot-devel] 404 page In-Reply-To: References: <7191141E-D10B-46FE-A8C4-2E6AD8171477@mac.com> Message-ID: 2014-05-08 15:07 GMT+02:00 Patrick May : > Removing the incorrect eql specialization still doesn't result in my 404 > page being displayed. Do I have to subclass acceptor to get it to work? > No, it works just fine without an extra subclass, e.g.: (defmethod hunchentoot:acceptor-status-message (acceptor (http-status-code (eql 404)) &key) "NOT FOUND") -Hans -------------- next part -------------- An HTML attachment was scrubbed... URL: From patrick.may at mac.com Thu May 8 14:30:21 2014 From: patrick.may at mac.com (Patrick May) Date: Thu, 08 May 2014 10:30:21 -0400 Subject: [Tbnl-devel] [hunchentoot-devel] 404 page In-Reply-To: References: <7191141E-D10B-46FE-A8C4-2E6AD8171477@mac.com> Message-ID: <52E4F78F-0B12-4F10-8AA6-1BC59550D21E@mac.com> Hmm. Here?s a full working example: (in-package :common-lisp-user) (ql:quickload :hunchentoot) (ql:quickload :drakma) (ql:quickload :cl-who) (defpackage :org.softwarematters.hunchentoot-test (:nicknames :hunchentoot-test :web-test) (:use :common-lisp :cl-who)) (in-package :web-test) ;;; Define the web server acceptor (defparameter *test-acceptor* (make-instance 'hunchentoot:easy-acceptor :port 8081 :document-root #p"/Users/Patrick/src/lisp/web/" :access-log-destination "/tmp/web-test-access.log" :message-log-destination "/tmp/web-test-message.log")) ;;; A couple of macros for encapsulating the details of a standard page. ;;; This came from Stack Overflow (How to connect a web app to Hunchentoot) ;;; and http://www.adampetersen.se/articles/lispweb.htm. (defmacro standard-page ((&key title) &body body) "Abstract away the placing of standard page stuff." `(with-html-output-to-string (*standard-output* nil :prologue t :indent t) (:html :xmlns "http://www.w3.org/1999/xhtml" :xml\:lang "en" :lang "en" (:head (:meta :http-equiv "content-type" :content "text/html;charset=UTF-8") (:title ,title) (:link :type "text/css" :rel "stylesheet" :href "/test.css")) (:body (:div :id "header") , at body (:div :id "footer"))))) (defmacro defpage (name (title) &body body) `(progn (defmethod ,name () (standard-page (,title) , at body)) (push (create-prefix-dispatcher ,(format nil "/~(~a~).html" name) ',name) *dispatch-table*))) ;;; URI implementations (defun display-home-page () "Display the home page." (hunchentoot:redirect "/index.html")) (push (hunchentoot:create-regex-dispatcher "^/$" 'display-home-page) hunchentoot:*dispatch-table*) (hunchentoot:define-easy-handler (home-page-handler :uri "/index.html" :default-request-type :GET) () "Return the home page." (standard-page (:title "Web Test Home Page") (:h1 "Web Test") (:p "remote IP address: " (format t "~A" (hunchentoot:remote-addr*))) (:p "real remote IP address: " (format t "~A" (hunchentoot:real-remote-addr))) (:p "headers: " (:br) (dolist (header (hunchentoot:headers-in*)) (format t "~A: ~A
" (car header) (cdr header)))) (:p "GET parameters: " (format t "~A" (hunchentoot:get-parameters*))))) ;;; Override 404 handling (defun display-404-page () (standard-page (:title "Web Test 404 Page") (:h1 "404"))) (defmethod acceptor-status-message (acceptor (http-status-code (eql 404)) &key) (display-404-page)) ;(defmethod hunchentoot:acceptor-status-message (acceptor (http-status-code (eql 404)) &key) "NOT FOUND") ;;; Start the web server (hunchentoot:start *test-acceptor*) I tried calling (display-404-page) in an easy-handler and it works fine. Thanks for any help. Regards, Patrick On May 8, 2014, at 9:12 AM, Hans H?bner wrote: > 2014-05-08 15:07 GMT+02:00 Patrick May : > Removing the incorrect eql specialization still doesn?t result in my 404 page being displayed. Do I have to subclass acceptor to get it to work? > > No, it works just fine without an extra subclass, e.g.: > > (defmethod hunchentoot:acceptor-status-message (acceptor (http-status-code (eql 404)) &key) "NOT FOUND") > > -Hans -------------- next part -------------- An HTML attachment was scrubbed... URL: From billstclair at gmail.com Thu May 8 14:41:45 2014 From: billstclair at gmail.com (Bill St. Clair) Date: Thu, 8 May 2014 10:41:45 -0400 Subject: [Tbnl-devel] [hunchentoot-devel] 404 page In-Reply-To: <52E4F78F-0B12-4F10-8AA6-1BC59550D21E@mac.com> References: <7191141E-D10B-46FE-A8C4-2E6AD8171477@mac.com> <52E4F78F-0B12-4F10-8AA6-1BC59550D21E@mac.com> Message-ID: Your example works for me if I change: (defmethod acceptor-status-message (acceptor (http-status-code (eql 404)) &key) (display-404-page)) to: (defmethod hunchentoot:acceptor-status-message (acceptor (http-status-code (eql 404)) &key) (display-404-page)) -Bill -------------- next part -------------- An HTML attachment was scrubbed... URL: From patrick.may at mac.com Thu May 8 16:23:59 2014 From: patrick.may at mac.com (Patrick May) Date: Thu, 08 May 2014 12:23:59 -0400 Subject: [Tbnl-devel] [hunchentoot-devel] 404 page In-Reply-To: References: <7191141E-D10B-46FE-A8C4-2E6AD8171477@mac.com> <52E4F78F-0B12-4F10-8AA6-1BC59550D21E@mac.com> Message-ID: <76C14664-E50B-4243-BF07-65B362946E24@mac.com> Thanks! Silently adding a new generic method ? one of my favorite tricks. Regards, Patrick On May 8, 2014, at 10:41 AM, Bill St. Clair wrote: > Your example works for me if I change: > > (defmethod acceptor-status-message (acceptor (http-status-code (eql 404)) &key) > (display-404-page)) > > to: > > (defmethod hunchentoot:acceptor-status-message (acceptor (http-status-code (eql 404)) &key) > (display-404-page)) > > -Bill -------------- next part -------------- An HTML attachment was scrubbed... URL: From patrick.may at mac.com Thu May 8 16:31:24 2014 From: patrick.may at mac.com (Patrick May) Date: Thu, 08 May 2014 12:31:24 -0400 Subject: [Tbnl-devel] [hunchentoot-devel] 404 page In-Reply-To: <76C14664-E50B-4243-BF07-65B362946E24@mac.com> References: <7191141E-D10B-46FE-A8C4-2E6AD8171477@mac.com> <52E4F78F-0B12-4F10-8AA6-1BC59550D21E@mac.com> <76C14664-E50B-4243-BF07-65B362946E24@mac.com> Message-ID: <403B1317-2636-4896-A5F2-07B2CD588CBD@mac.com> I spoke too soon. I changed it to specify hunchentoot:acceptor-status-messsage, but no joy. Then I modified the package to use :hunchentoot and removed all the ?hunchentoot:? package specifiers in the code, but still see the default 404 page in my browser. I?m using Clozure CL (64-bit) on OS X. Thanks, Patrick On May 8, 2014, at 12:23 PM, Patrick May wrote: > Thanks! Silently adding a new generic method ? one of my favorite tricks. > > Regards, > > Patrick > > On May 8, 2014, at 10:41 AM, Bill St. Clair wrote: > >> Your example works for me if I change: >> >> (defmethod acceptor-status-message (acceptor (http-status-code (eql 404)) &key) >> (display-404-page)) >> >> to: >> >> (defmethod hunchentoot:acceptor-status-message (acceptor (http-status-code (eql 404)) &key) >> (display-404-page)) >> >> -Bill > > _______________________________________________ > Tbnl-devel mailing list > Tbnl-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/tbnl-devel -------------- next part -------------- An HTML attachment was scrubbed... URL: From billstclair at gmail.com Thu May 8 16:38:18 2014 From: billstclair at gmail.com (Bill St. Clair) Date: Thu, 8 May 2014 12:38:18 -0400 Subject: [Tbnl-devel] [hunchentoot-devel] 404 page In-Reply-To: <403B1317-2636-4896-A5F2-07B2CD588CBD@mac.com> References: <7191141E-D10B-46FE-A8C4-2E6AD8171477@mac.com> <52E4F78F-0B12-4F10-8AA6-1BC59550D21E@mac.com> <76C14664-E50B-4243-BF07-65B362946E24@mac.com> <403B1317-2636-4896-A5F2-07B2CD588CBD@mac.com> Message-ID: Same here. hunchentoot:*hunchentoot-version* is "1.2.26" (lisp-implementation-version) is "Version 1.9-r16025M (DarwinX8664)" -Bill On Thu, May 8, 2014 at 12:31 PM, Patrick May wrote: > I spoke too soon. I changed it to specify > hunchentoot:acceptor-status-messsage, but no joy. Then I modified the > package to use :hunchentoot and removed all the ?hunchentoot:? package > specifiers in the code, but still see the default 404 page in my browser. > > I?m using Clozure CL (64-bit) on OS X. > > Thanks, > > Patrick > > On May 8, 2014, at 12:23 PM, Patrick May wrote: > > Thanks! Silently adding a new generic method ? one of my favorite tricks. > > Regards, > > Patrick > > On May 8, 2014, at 10:41 AM, Bill St. Clair wrote: > > Your example works for me if I change: > > (defmethod acceptor-status-message (acceptor (http-status-code (eql 404)) > &key) > (display-404-page)) > > to: > > (defmethod hunchentoot:acceptor-status-message (acceptor (http-status-code > (eql 404)) &key) > (display-404-page)) > > -Bill > > > _______________________________________________ > Tbnl-devel mailing list > Tbnl-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/tbnl-devel > > > > _______________________________________________ > Tbnl-devel mailing list > Tbnl-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/tbnl-devel > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From patrick.may at mac.com Thu May 8 20:20:04 2014 From: patrick.may at mac.com (Patrick May) Date: Thu, 08 May 2014 16:20:04 -0400 Subject: [Tbnl-devel] [hunchentoot-devel] 404 page In-Reply-To: References: <7191141E-D10B-46FE-A8C4-2E6AD8171477@mac.com> <52E4F78F-0B12-4F10-8AA6-1BC59550D21E@mac.com> <76C14664-E50B-4243-BF07-65B362946E24@mac.com> <403B1317-2636-4896-A5F2-07B2CD588CBD@mac.com> Message-ID: That was it. I updated to 1.2.26 from 1.2.21 and it worked. Thanks for the help! Regards, Patrick On May 8, 2014, at 12:38 PM, Bill St. Clair wrote: > Same here. > > hunchentoot:*hunchentoot-version* is "1.2.26" > (lisp-implementation-version) is "Version 1.9-r16025M (DarwinX8664)" > > -Bill > > > On Thu, May 8, 2014 at 12:31 PM, Patrick May wrote: > I spoke too soon. I changed it to specify hunchentoot:acceptor-status-messsage, but no joy. Then I modified the package to use :hunchentoot and removed all the ?hunchentoot:? package specifiers in the code, but still see the default 404 page in my browser. > > I?m using Clozure CL (64-bit) on OS X. > > Thanks, > > Patrick > > On May 8, 2014, at 12:23 PM, Patrick May wrote: > >> Thanks! Silently adding a new generic method ? one of my favorite tricks. >> >> Regards, >> >> Patrick >> >> On May 8, 2014, at 10:41 AM, Bill St. Clair wrote: >> >>> Your example works for me if I change: >>> >>> (defmethod acceptor-status-message (acceptor (http-status-code (eql 404)) &key) >>> (display-404-page)) >>> >>> to: >>> >>> (defmethod hunchentoot:acceptor-status-message (acceptor (http-status-code (eql 404)) &key) >>> (display-404-page)) >>> >>> -Bill >> >> _______________________________________________ >> Tbnl-devel mailing list >> Tbnl-devel at common-lisp.net >> http://common-lisp.net/cgi-bin/mailman/listinfo/tbnl-devel > > > _______________________________________________ > Tbnl-devel mailing list > Tbnl-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/tbnl-devel > > -------------- next part -------------- An HTML attachment was scrubbed... URL: