--- Begin Message ---
Evrim Ulu wrote:
== Web Framework ==

Our new web framework is like the PLT's. We did want small/compact and easily testable web framework.
Oh what is easily testable? Here is an example:

(defun/cc template2 (&optional body)
 (<:html
(<:head (<:meta :content "text/html; charset=utf-8" :http--equiv "Content-Type")
      (<:title "Sample form page"))
  (funcall body)))

(defun/cc feedback2-form ()
 (<:div :class "feedback-form"
(<:form :action (function/url ((name "name") (email "email") (message "message"))
              (let ((msg (make-mail
                      (format nil "Message from: ~A <~A>" name email)
                      message)))
                (answer (list "[EMAIL PROTECTED]" msg))))
        :method "POST"
        (tabularize 2
(<:ai "Name:") (<:input :name "name" :type "text") (<:ai "E-Mail:") (<:input :name "email" :type "text")
          (<:ai "Message") (<:textarea :name "message"))
        (<:input :name "Send" :value "Send" :type "submit"))))

(defurl *app* "form.php" ()
 (send/suspend (template2 #'feedback2-form)))

MEDITATE-EU> (test-url "form.php" *app*)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html
   ><head
     ><meta content="text/html; charset=utf-8" http-equiv="Content-Type"
     /><title
       >Sample form page</title
     ></head
   ><div class="feedback-form"
     ><form method="POST" action="?s=JrOtAkBx&amp;k=fun-FXQ"
       ><table
         ><tr
           ><td
             >Name:</td
           ><td
             ><input type="text" name="name"
             /></td
           ></tr
         ><tr
           ><td
             >E-Mail:</td
           ><td
             ><input type="text" name="email"
             /></td
           ></tr
         ><tr
           ><td
             >Message</td
           ><td
             ><textarea name="message"
               ></textarea
             ></td
           ></tr
         ></table
       ><input value="Send" type="submit" name="Send"
       /></form
     ></div
   ></html
 >
(("fun-FXQ" . #<IT.BESE.ARNESI::CLOSURE/CC {1005F057B9}>))
MEDITATE-EU> (kontinue (cdar **) "John Doe" "[EMAIL PROTECTED]" "My message is peace!")
("[EMAIL PROTECTED]"
"Subject: Message from: #<HTTP-REQUEST {10027E8311}> <#<HTTP-RESPONSE {10027E94E1}>>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

John Doe
")

test-url returns page continuations and we invoke the first one with sample parameters. So, we can define a RT test:

(rt::deftest form.php
(equal (kontinue 0 (test-url "form.php" *app*) "John Doe" "[EMAIL PROTECTED]" "My message is peace!")
   '("[EMAIL PROTECTED]" "Subject: Message from: John Doe <[EMAIL PROTECTED]>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

My message is peace!
"))
 t)

REPL> (rt::do-test 'form.php)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html
   ><head
     ><meta content="text/html; charset=utf-8" http-equiv="Content-Type"
     /><title
       >Sample form page</title
     ></head
   ><div class="feedback-form"
     ><form method="POST" action="?s=qYAVYelB&amp;k=fun-TGH"
       ><table
         ><tr
           ><td
             >Name:</td
           ><td
             ><input type="text" name="name"
             /></td
           ></tr
         ><tr
           ><td
             >E-Mail:</td
           ><td
             ><input type="text" name="email"
             /></td
           ></tr
         ><tr
           ><td
             >Message</td
           ><td
             ><textarea name="message"
               ></textarea
             ></td
           ></tr
         ></table
       ><input value="Send" type="submit" name="Send"
       /></form
     ></div
   ></html
 >
FORM.PHP

Best Regards,

--
Aycan iRiCAN
Kor Bilişim Ltd. Şti.
http://www.core.gen.tr/

_______________________________________________
bese-devel mailing list
[EMAIL PROTECTED]
http://common-lisp.net/cgi-bin/mailman/listinfo/bese-devel

--- End Message ---
_______________________________________________
cs-lisp mailing list
cs-lisp@cs.bilgi.edu.tr
http://church.cs.bilgi.edu.tr/lcg
http://cs.bilgi.edu.tr/mailman/listinfo/cs-lisp

Cevap