[Bese-devel] ucw and new core-server

Aycan iRiCAN aycan.irican at core.gen.tr
Sat Dec 22 15:36:28 UTC 2007


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 "aycan at core.gen.tr" 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&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" "john at doe.com" "My message 
is peace!")
("aycan at core.gen.tr"
 "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" 
"john at doe.com" "My message is peace!")
    '("aycan at core.gen.tr" "Subject: Message from: John Doe <john at doe.com>
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&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/




More information about the bese-devel mailing list