dropdowns, form views

1 view
Skip to first unread message

Daniel Brooks

unread,
Sep 26, 2009, 7:32:00 PM9/26/09
to webl...@googlegroups.com
I have a scope class that has an owner slot; the value of the owner slot
is always nil or a user object. I'm trying to make the basic form view
present a dropdown list of all the available users when both adding a
new scope and editing an existing one. To that end I've defined a view:

(defview scope-form-view (:type form :inherit-from '(:scaffold scope))
(owner :present-as (dropdown :choices #'all-users) :parse-as user)
(parent :present-as (dropdown :choices #'all-scopes) :parse-as scope))

as well as a presentation class and a parser class. This works fine when
adding a new scope object, but not when editing an existing one. When
editing an existing one I get this error:

SIMPLE-ERROR: There is no applicable method for the generic function
#<STANDARD-GENERIC-FUNCTION ATTRIBUTIZE-NAME (4)> when called with
arguments (#<USER {1003D7CC11}>).

I've spent a few hours poking around, losing myself in the usual twisty
maze, and I can't figure out what's going on. formview.lisp defines a
with-view-header method that calls (attributize-name (object-view-class
obj)), but there's no way that would end up calling attributize-name on
a list of user objects. If obj were a list it would end up calling
attributize-name on the symbol cons. What am I missing? What's the
difference between a form-view that's showing me an existing object and
one that's showing me me a newly-minted object?

db48x

Daniel Brooks

unread,
Sep 26, 2009, 9:43:34 PM9/26/09
to webl...@googlegroups.com
Daniel Brooks <db...@yahoo.com> writes:

> SIMPLE-ERROR: There is no applicable method for the generic function
> #<STANDARD-GENERIC-FUNCTION ATTRIBUTIZE-NAME (4)> when called with
> arguments (#<USER {1003D7CC11}>).

Ok, I spent a little more time on it and figured it out. The problem I'm
having comes from the method render-view-field-value specialized for the
dropdown-presentation (in views/types/presentations/dropdown.lisp). It
calls attributize-name on the value to be rendered in order to render
the dropdown with the correct item selected. However, when the slot it's
rendering a field for contains an object then this isn't the best
approach. If I make it call (presentation-choices-default-value-key
value) then it works perfectly. Because
presentation-choices-default-value-key calls attributize-name for values
that aren't objects, I think this is the right behavior in all cases.

db48x

Leslie P. Polzer

unread,
Sep 29, 2009, 4:25:49 AM9/29/09
to weblocks
Hi Daniel,
Care to post a patch for this one? This will make it easier for me to
understand
and review it.

Daniel Brooks

unread,
Sep 29, 2009, 12:26:03 PM9/29/09
to webl...@googlegroups.com
"Leslie P. Polzer" <leslie...@gmx.net> writes:

> Care to post a patch for this one? This will make it easier for me to
> understand
> and review it.

Sure. I set it up on bitbucket.org, but here's the diff in case you
prefer it. It's not a very large change :)

diff -r ea298f9a600b src/views/types/presentations/dropdown.lisp
--- a/src/views/types/presentations/dropdown.lisp Mon Sep 07 16:50:06 2009 +0200
+++ b/src/views/types/presentations/dropdown.lisp Tue Sep 29 11:10:14 2009 -0500
@@ -33,6 +33,6 @@
:selected-value (if intermediate-value-p
intermediate-value
(when value
- (attributize-name value)))
+ (presentation-choices-default-value-key value)))
:id *presentation-dom-id*)))

Leslie P. Polzer

unread,
Sep 29, 2009, 1:09:55 PM9/29/09
to weblocks

IIRC I made this change myself for one of my projects but didn't get
around
to put it into upstream.

> Sure. I set it up on bitbucket.org, but here's the diff in case you
> prefer it. It's not a very large change :)

Thanks, I prefer pulling from forks indeed.

I guess it doesn't break any tests?

Leslie

Leslie P. Polzer

unread,
Sep 29, 2009, 1:33:39 PM9/29/09
to webl...@googlegroups.com

Leslie P. Polzer wrote:

> I guess it doesn't break any tests?

No, it does not.

Reply all
Reply to author
Forward
0 new messages