functionslimehunchentoot

Hunchentoot : function does not work within webpage but is totally fine when used in slime


I am newly working with hunchentoot. Anyway i am doing a webpage for managing a simple todo list following this tutorial. I have a problem with my deletetodo function defined :

(defun deletetodo (todoid) (setf *todos* (remove (find todoid *todos* :test #'equal :key #'todocid) *todos*)))     

When i run (deletetodo id) from slime it works perfect and the note get deleted.

But when i run it from my hunchertoot server it doesn't return any error but it doesn't delete anything ! this is my function for calling deletid page:

(define-url-fn (deleteid)
 (let ((id  (parameter "id")))
  (deletetodo id)
  (redirect "/menu.html")))  

The following page was called with deleteid.html?id=1 , supposing 1 is an example. I tried tracing the request and it's totally correct and the correct id is sent but deletetodo just don't work! Any ideas?


Solution

  • I feel stupid :) it's just a formatting issue, the id value sent withing the request is in string format, but what is needed is an int. So using (read-from-string id) fixes the issue.