Chris Dean | 1 Jun 2006 01:58
Favicon
Gravatar

Arnesi patch: Support missing result forms in cond-bind and acond


Below is a patch for COND-BIND and ACOND to support missing result
forms.  I've also included a small test suite for the flow-control
operators.

Let me know if you would like the patch in a different format.

Cheers,
Chris Dean

New patches:

[Support missing result forms in cond-bind and acond
Chris Dean <ctdean <at> sokitomi.com>**20060531234605

 The CLHS says that COND results in:

   the values of the forms in the first clause whose test-form yields
   true, or the primary value of the test-form if there are no forms in
   that clause

 Meaning (among other things) that 

   (cond (1)) => 1

 This is a patch to give COND-BIND and ACOND the same behavior.  Before
 this patch they would return NIL if there was a missing result form.

] {
hunk ./arnesi.asd 72
(Continue reading)

hbabcockos1 | 1 Jun 2006 03:21
Picon

Re: Re: utf-8 encoding problem


On May 30, 2006, at 6:52 AM, Marco Baringer wrote:
>
> we've recently tried to make utf-8 output easier, or so we thought...

It is easy once you figure out what you are doing :). Thanks all for  
the help and suggestions! The root of the problem was my confusion  
concerning 'character, '(unsigned-byte 8) and unicode strings.

-Hazen
Marijn Haverbeke | 1 Jun 2006 13:55
Picon
Gravatar

<ucw:select with :multiple t

I am unsure whether this is a bug or me being dumb, but when I add an <ucw:select field that allows multiple values like this:

         (<ucw:select :multiple t :accessor (slot-value page 'testslot)
                      (<ucw:option :value 1 "a")
                      (<ucw:option :value 2 "b")
                      (<ucw:option :value 3 "c"))

...the select element will indeed allow multiple rows to be selected, and the value that is put into the component slot is indeed a list instead of a single value, but it only contains one element, even when I select multiple elements before submitting. How do I fix this?

Thanks,
Marijn

_______________________________________________
bese-devel mailing list
bese-devel <at> common-lisp.net
http://common-lisp.net/cgi-bin/mailman/listinfo/bese-devel
Marijn Haverbeke | 2 Jun 2006 12:18
Picon
Gravatar

<ucw: input elements and javascript

Hi again,

After happily playing with the <ucw:select, <ucw:text etc tags and there :accessors for a while, I came across situations where I needed to have javascript read and write to the value of such elements client-side. Since their values all seem to contain mysteriously hashed strings, this will not work. Is there a way around this? For example a way to turn off the hashing (it seems that is only necessary if you want to store lisp objects in them). Right now I'm messily working around them by using normal input fields and reading the post values from the request in order to store them in my component again... basically re-implementing the :accessor functionality.

Also, it seems that there is no way to get at the parameters of a request object without using internal ucw symbols. Is this intentional, or also a case of forgetting to export a symbol?

That being said, this framework really rocks. Coming from PHP, it's a delight to use.

Regards,
Marijn

_______________________________________________
bese-devel mailing list
bese-devel <at> common-lisp.net
http://common-lisp.net/cgi-bin/mailman/listinfo/bese-devel
Marijn Haverbeke | 2 Jun 2006 13:44
Picon
Gravatar

Re: <ucw: input elements and javascript


After happily playing with the <ucw:select, <ucw:text etc tags and there :accessors for a while, I came across situations where I needed to have javascript read and write to the value of such elements client-side. Since their values all seem to contain mysteriously hashed strings, this will not work. Is there a way around this? For example a way to turn off the hashing (it seems that is only necessary if you want to store lisp objects in them). Right now I'm messily working around them by using normal input fields and reading the post values from the request in order to store them in my component again... basically re-implementing the :accessor functionality.

Of course, in my previous mail I was actually only referring to 'select' and 'hidden' tags, because other kinds can be manipulated in javascript just fine.

Also, I think there is a bug with <ucw:input tags that have :type "checkbox" - browsers do not seem to add a variable to a request for an unchecked checkbox, causing the :accessor or :writer on such tags to never run when the box is unchecked.

Marijn
_______________________________________________
bese-devel mailing list
bese-devel <at> common-lisp.net
http://common-lisp.net/cgi-bin/mailman/listinfo/bese-devel
Marco Baringer | 4 Jun 2006 19:14
Picon

Re: <ucw:select with :multiple t

"Marijn Haverbeke" <marijnh <at> gmail.com> writes:

> ...the select element will indeed allow multiple rows to be selected, and the
> value that is put into the component slot is indeed a list instead of a single
> value, but it only contains one element, even when I select multiple elements
> before submitting. How do I fix this?

what backend is this?

--

-- 
-Marco
Ring the bells that still can ring.
Forget your perfect offering.
There is a crack in everything.
That's how the light gets in.
	-Leonard Cohen
Marco Baringer | 4 Jun 2006 19:18
Picon

Re: <ucw: input elements and javascript

"Marijn Haverbeke" <marijnh <at> gmail.com> writes:

> Hi again,
>
> After happily playing with the <ucw:select, <ucw:text etc tags and there
> :accessors for a while, I came across situations where I needed to have
> javascript read and write to the value of such elements client-side. Since
> their values all seem to contain mysteriously hashed strings, this will not
> work. Is there a way around this? For example a way to turn off the hashing (it
> seems that is only necessary if you want to store lisp objects in them). Right
> now I'm messily working around them by using normal input fields and reading
> the post values from the request in order to store them in my component
> again... basically re-implementing the :accessor functionality.

all the tags take a :name parameter (and if they don't it's a bug)
which allows you to specify what http request parameter name to
use. all the tags also take an :id parameter, you can set that and
then use document.getElementById or whatever.

the form stuff (src/components/form.lisp) makes a lot of this easier,
you could look into those.

> Also, it seems that there is no way to get at the parameters of a request
> object without using internal ucw symbols. Is this intentional, or also a case
> of forgetting to export a symbol?

get-parameter sholud have been exported, my bad.

--

-- 
-Marco
Ring the bells that still can ring.
Forget your perfect offering.
There is a crack in everything.
That's how the light gets in.
	-Leonard Cohen
Steve Salkin | 6 Jun 2006 07:12

backtracking.lisp: compile issue

Hi,

I wonder if this rings a bell with anyone? The code doesn't look 
problematic to me at a glance, but I am not really used to CPS/arnesi style.

; compiling file 
"/home/steve/.sbcl/site/ucw_dev/src/rerl/backtracking.lisp" (written 27 
MAY 2006 08:18:37 AM):
; compiling (IN-PACKAGE :IT.BESE.UCW)
; compiling (DEFMACRO MAKE-PLACE ...)
; compiling (DEFMETHOD PLACE ...)
; file: /home/steve/.sbcl/site/ucw_dev/src/rerl/backtracking.lisp
; in: DEFMETHOD PLACE (PLACE)
;     (DEFMETHOD IT.BESE.UCW::PLACE
;              ((IT.BESE.UCW::PLACE IT.BESE.UCW::PLACE))
;              "Returns the current value of PLACE."
;              (ETYPECASE (IT.BESE.UCW::PLACE.GETTER IT.BESE.UCW::PLACE)
;                (FUNCTION
;                 (FUNCALL (IT.BESE.UCW::PLACE.GETTER IT.BESE.UCW::PLACE)))
;                (IT.BESE.ARNESI::CLOSURE/CC
;                 (IT.BESE.ARNESI:WITH-CALL/CC (FUNCALL #)))))
;
; caught WARNING:
;   Reference to unknown variable PLACE.

; compiling (DEFMETHOD (SETF PLACE) ...)
; file: /home/steve/.sbcl/site/ucw_dev/src/rerl/backtracking.lisp
; in: DEFMETHOD (SETF PLACE) (T PLACE)
;     (DEFMETHOD (SETF IT.BESE.UCW::PLACE)
;              (IT.BESE.UCW:VALUE (IT.BESE.UCW::PLACE IT.BESE.UCW::PLACE))
;              "Set the value of PLACE to VALUE."
;              (ETYPECASE (IT.BESE.UCW::PLACE.SETTER IT.BESE.UCW::PLACE)
;                (FUNCTION
;                 (FUNCALL (IT.BESE.UCW::PLACE.SETTER IT.BESE.UCW::PLACE)
;                          IT.BESE.UCW:VALUE))
;                (IT.BESE.ARNESI::CLOSURE/CC
;                 (IT.BESE.ARNESI:WITH-CALL/CC (FUNCALL # 
IT.BESE.UCW:VALUE)))))
;
; caught WARNING:
;   Reference to unknown variable PLACE.
;
; caught WARNING:
;   Reference to unknown variable VALUE.

Details:

On a fresh checkout of ucw_dev with no old fasls, using sbcl 0.9.13.8, I 
ran sbcl and did the following:
(require 'asdf)
(asdf:oos 'asdf:load-op :fiveam) ; needed because the next line bombs 
otherwise
(load "/home/steve/.ucw/start.lisp")

~/.ucw has copies of start.lisp, stop.lisp, conf.lisp, ucwctl.conf with 
appropriate values for this machine

Any thoughts appreciated :)

S-
Attila Lendvai | 6 Jun 2006 09:31
Picon
Gravatar

Re: backtracking.lisp: compile issue

> ; in: DEFMETHOD PLACE (PLACE)
> ;     (DEFMETHOD IT.BESE.UCW::PLACE
> ;              ((IT.BESE.UCW::PLACE IT.BESE.UCW::PLACE))
> ;              "Returns the current value of PLACE."
> ;              (ETYPECASE (IT.BESE.UCW::PLACE.GETTER IT.BESE.UCW::PLACE)
> ;                (FUNCTION
> ;                 (FUNCALL (IT.BESE.UCW::PLACE.GETTER IT.BESE.UCW::PLACE)))
> ;                (IT.BESE.ARNESI::CLOSURE/CC
> ;                 (IT.BESE.ARNESI:WITH-CALL/CC (FUNCALL #)))))
> ;
> ; caught WARNING:
> ;   Reference to unknown variable PLACE.

recently Marco enabled arnesi call/cc warnings for unknown variable
references and it's probably a bug with defmethod's argument handling
in the cps transform. i've seen this here, too...

> On a fresh checkout of ucw_dev with no old fasls, using sbcl 0.9.13.8, I
> ran sbcl and did the following:
> (require 'asdf)
> (asdf:oos 'asdf:load-op :fiveam) ; needed because the next line bombs
> otherwise

this is a bug in rfc2109.asd i have a patch for locally with another
small bugfix. if somebody can add me (alendvai) to the group i can
check them in. or i'll send the patch, but i've warned the author
about the missing 5am dependency long ago.

- attila

(alias 101 on irc &no 'its not lisp code :)
Marijn Haverbeke | 7 Jun 2006 13:50
Picon
Gravatar

A field class for multiple select inputs

Hi,

Following is a field class for select elements that allow you to select more than one options. Unless I missed something, there is no class yet for select elements like that. This could be added to components/form.lisp to implement that. BUT, you'll probably notice the really ugly hack with the hidden input whose callback grabs all the values for the select input out of the parameters. If there is a better way to run code when a request is made I'd like to hear about it, so I can make a prettier implementation.

Maybe the callback mechanism needs some rethinking anyway? The (setf (client-value field) nil) in the render method of checkbox-field is also a case of code that should always be run before the parameters are handled, and does not really belong in a render method. Maybe add a way to register special callbacks for a form that allways run before the other callbacks? It seems forms already add a hidden variable to identify themselves, that could be used to decide which form-specific callbacks are run.

Currently normal callbacks are not form-specific, are they? I mean, if there are two forms on a page, and both have a field called 'name', will the two callbacks for those fields coexist peacefully or will they override each other?

Also, did you know that many xxx-field classes ignore the :name slot and just generate a random name (though make-new-callback)? Is this a bug or a feature?

Well, here's the code, for what it's worth:

(defclass multiple-select-field (select-field)
  ()
  (:default-initargs :name (random-string 8) :client-value ()))

(defmethod render ((field multiple-select-field))
  (<:ai (value field))
  (<:input :type "hidden" :value "x"
           :name (make-new-callback
                  (lambda (value)
                    (declare (ignore value))
                    (do ((vars (slot-value (context.request *context*) 'parameters) (cdr vars))
                         (result ()))
                        ((null vars) (setf (client-value field) result))
                      (if (string= (caar vars) (name field))
                          (push (cdar vars) result))))))
  (<:select :name (name field) :tabindex (tabindex field) :multiple t
            (setf (data-map field) (build-data-map field))
            (render-options field)))

(defmethod render-options ((field multiple-select-field))
  (dolist* ((key-string . value) (data-map field))
    (<:option :value key-string
              :selected  (member key-string (client-value field) :test #'string=)
              (render-value field value))))

(defmethod value ((field multiple-select-field))
  (mapcar (lambda (x)
            (cdr (assoc x (data-map field) :test #'string=)))
          (client-value field)))

_______________________________________________
bese-devel mailing list
bese-devel <at> common-lisp.net
http://common-lisp.net/cgi-bin/mailman/listinfo/bese-devel

Gmane