N00B Question

6 views
Skip to first unread message

Michael McDermott

unread,
Sep 30, 2009, 2:26:01 PM9/30/09
to webl...@googlegroups.com
I am trying to set up some basic user authentication, authorization, etc. Whenever I try to use the login page (generated, of course, with the login widget) I get the error:

SIMPLE-ERROR: Cannot determine object ID. Object #<G1496 {AA34A41}> has no slot 'id'.

The code to set up the form is:

(defun init-user-session (comp)
    (if (not (authenticatedp))
            (setf (widget-children comp)
                  (list (make-instance 'login
                                       :view 'login-view
                                       :login-quickform (make-quickform 'login-view)
                                       :on-login (lambda (form data)
                                            (with-slots (email password) data
                                            (if (or (null password)
                                                    (null email))
                                                    nil
                                                    (make-instance 'user))))
                                                ))
                                       )))

As you can see, this is little more than a stub just to start laying things out. The class user is:

(defclass user ()
    ((id :initarg :id :initform nil :accessor id)
     (status :type (member :active :inactive)
             :initarg :status
             :initform :active)
     (email :type string
            :accessor email
            :initarg :email)
     (first-name :type string
                 :initarg :first-name)
     (last-name :type string
                :initarg :last-name)
     (password :type string
               :accessor password
               :initarg :password)
     ))

(defview login-view
    (:type form
     :caption "Login")
    (email :requiredp t)
    (password :present-as (password) :requiredp t))

From the trace, it is obvious that the Prevalence store is what is throwing the error (I can attach the full trace, if needed). I am running revision 1587 from the dev repository. If anyone can help straighten me out, it would be very much appreciated.

-Michael

nunb

unread,
Sep 30, 2009, 3:03:36 PM9/30/09
to weblocks

> SIMPLE-ERROR: Cannot determine object ID. Object #<G1496 {AA34A41}> has no
> slot 'id'.
>

As a first step does removing the :initform nil help?

If you are using slime, can you check what the type of the object
G1496 is? (That is, verify that it is carping about a missing id in
instance of class 'user).

Michael McDermott

unread,
Sep 30, 2009, 3:14:34 PM9/30/09
to webl...@googlegroups.com
As a first step does removing the :initform nil help?

That has no effect.


If you are using slime, can you check what the type of the object
G1496 is? (That is, verify that it is carping about a missing id in
instance of class 'user).

I actually have no idea what G1496 is. The number after "G" changes. I assume it is not an instance of user, because this happens from the REPL when in the same package as the web app:

* (let ((a (make-instance 'user :id 1))) (slot-value a 'zanzibar))

debugger invoked on a SIMPLE-ERROR in thread #<THREAD "initial thread" RUNNING {A834761}>:
  When attempting to read the slot's value (slot-value), the slot ZANZIBAR is
  missing from the object #<USER {B7E5851}>.

"zanzibar" is really not a member of user, but the snippet generates an equivalent error with the type listed in the error.

Thanks for the feedback.

-Michael

Leslie P. Polzer

unread,
Sep 30, 2009, 3:25:56 PM9/30/09
to weblocks
On Sep 30, 8:26 pm, Michael McDermott <mcdermott.micha...@gmail.com>
wrote:

> From the trace, it is obvious that the Prevalence store is what is throwing
> the error (I can attach the full trace, if needed).

Yes, the full backtrace will be helpful in this.

Leslie

nunb

unread,
Sep 30, 2009, 3:32:44 PM9/30/09
to weblocks
Does the error come when you hit the login page? Or does it come when
you load the system?

What happens if you run (weblocks::reset-sessions) at the REPL?

What is the result of removing fasls and recompiling?

If you had earlier declared the class user *sans* id, and it got saved
to the cl-prevalence store (used by default) this error may occur when
cl-prevalence attempts to load its store. Quitting lisp and removing
all files in the data/ directory will eliminate this as a potential
error source.

The full backtrace will certainly help: paste.lisp.org


> assume it is not an instance of user, because this happens from the REPL
> when in the same package as the web app:
>
> * (let ((a (make-instance 'user :id 1))) (slot-value a 'zanzibar))
>
> debugger invoked on a SIMPLE-ERROR in thread #<THREAD "initial thread"
> RUNNING {A834761}>:
>   When attempting to read the slot's value (slot-value), the slot ZANZIBAR
> is
>   missing from the object #<USER {B7E5851}>.
>
> "zanzibar" is really not a member of user, but the snippet generates an
> equivalent error with the type listed in the error.
>

Considering that earlier it carped about Object #<G1496 {AA34A41}> I
would hazard that it's a problem with your prevalence store and that
deleting data/* would be a good step. I assume you're not using
Elephant or any other storage mechanisms.

Michael McDermott

unread,
Sep 30, 2009, 3:50:49 PM9/30/09
to webl...@googlegroups.com
Full backtrace, from Weblocks' error page is here: http://paste.lisp.org/+1VVF Weblocks throws the error after the login form is submitted.


What happens if you run (weblocks::reset-sessions) at the REPL?

It executes without error. I do this every time I reload the ASDF package. Same thing happens.


What is the result of removing fasls and recompiling?

No change. Still throws the error.

Quitting lisp and removing all files in the data/ directory will eliminate this as a potential error source.

Just tried this--no change.


would hazard that it's a problem with your prevalence store and that
deleting data/* would be a good step. I assume you're not using
Elephant or any other storage mechanisms.

No--using the default Prevalence store.

-Michael

Daniel Brooks

unread,
Sep 30, 2009, 3:57:48 PM9/30/09
to webl...@googlegroups.com
Michael McDermott <mcdermott...@gmail.com> writes:

> SIMPLE-ERROR: Cannot determine object ID. Object #<G1496 {AA34A41}> has no
> slot 'id'.

(defmethod class-id-slot-name ((class t))
'id)

It's a silly thing to have to do, but I guess the 'id it's looking for
is in the weblocks package, and the one you're defining is in your
package. There should be a better way.

db48x

Leslie P. Polzer

unread,
Sep 30, 2009, 3:59:15 PM9/30/09
to weblocks
On Sep 30, 9:50 pm, Michael McDermott <mcdermott.micha...@gmail.com>
wrote:
> Full backtrace, from Weblocks' error page is here:
> http://paste.lisp.org/+1VVFWeblocks throws the error after the
> login form is submitted.

You need to specify :persistp nil for your login view. Cf. the default
login view:

(defview default-login-view (:type form :persistp nil
:buttons '((:submit . "Login") :cancel)
:caption "Login"
:focusp t)
(email :requiredp t)
(password :requiredp t
:present-as password
:writer (lambda (pwd obj)
(setf (slot-value obj 'password)
(hash-password pwd)))))

Michael McDermott

unread,
Sep 30, 2009, 4:08:30 PM9/30/09
to webl...@googlegroups.com
Adding :persistp nil to the form options seems to have done it. Thanks. I knew it had to be something so simple, that I'd feel stupid as soon as I knew what it was... :)

-Michael

Leslie P. Polzer

unread,
Oct 1, 2009, 2:19:37 AM10/1/09
to weblocks
On Sep 30, 10:08 pm, Michael McDermott <mcdermott.micha...@gmail.com>
wrote:
> Adding :persistp nil to the form options seems to have done it. Thanks. I
> knew it had to be something so simple, that I'd feel stupid as soon as I
> knew what it was... :)

But do you understand why this is needed?

Michael McDermott

unread,
Oct 2, 2009, 9:35:08 AM10/2/09
to webl...@googlegroups.com
Well, so far as I can understand, it is necessary because the form view will be persisted upon submitting by default. Since, in this case, there was no id on the form and the Prevalence storage engine requires an id slot, an error was thrown.

Leslie P. Polzer

unread,
Oct 2, 2009, 10:52:58 AM10/2/09
to weblocks
On Oct 2, 3:35 pm, Michael McDermott <mcdermott.micha...@gmail.com>
wrote:
> Well, so far as I can understand, it is necessary because the form view will
> be persisted upon submitting by default. Since, in this case, there was no
> id on the form and the Prevalence storage engine requires an id slot, an
> error was thrown.

To clarify this a bit then: quickform creates a temporary object based
on
the view. This object should not be persisted and doesn't have an id
slot.

Leslie
Reply all
Reply to author
Forward
0 new messages