I've converted my weblocks app to use elephant. One of the first things I do is to initialize some variables. One of the variables is a "demo" item, that I use as a placeholder until the user choses something more specific. I'm having trouble initializing the dummy. Here is my code:<br>
<br>(defun init-dummy-item ()<br> (let* ((ref-type 0)<br> (ref-id "dummy-item"))<br> (setf *dummy-item*<br> (unless-use (awhen (elephant:get-instances-by-value 'product-item 'reference-id ref-id)<br>
(find-if (lambda (item)<br> (eql (product-item-reference-type item) ref-type))<br> it))<br> (make-instance<br>
'product-item<br> :reference-type ref-type<br> :reference-id ref-id<br> :title "No Item selected"<br> :url "/pub/static/dummy.html"<br>
:image-url "/pub/images/dummy.png")))))<br><br>(The UNLESS-USE macro simply does unless, and if results are nil uses the second sexp.)<br><br>The problem is that I get an error (see trace below) when calling GET-INSTANCES-BY-VALUE. What am I doing wrong?<br>
<br>The nearest that I can gather is that GET-VALUE is called with the secondd argument as NIL, but it's supposed to be something reasonable, i.e a controller-index-table held by the controler. For whatever raeson that's NIL. What's the deal here? Am I not alowed to call the get-instances-by-* methods until I create at least one item for each class I'm querying about?<br>
<br>Yarek<br><br>THE ERROR:<br><br>There is no applicable method for the generic function<br> #<STANDARD-GENERIC-FUNCTION ELEPHANT:GET-VALUE (3)><br>when called with arguments<br> ((FASHION-ORIGAMI::PRODUCT-ITEM<br>
. FASHION-ORIGAMI::REFERENCE-ID)<br> NIL).<br> [Condition of type SIMPLE-ERROR]<br><br>Restarts:<br> 0: [TERMINATE-THREAD] Terminate this thread (#<THREAD "hunchentoot-worker-4" RUNNING {10029A0321}>)<br>
<br>Backtrace:<br> 0: ((LAMBDA (SWANK-BACKEND::DEBUGGER-LOOP-FN)) #<FUNCTION (LAMBDA #) {1003F6A4C9}>)<br> 1: (SWANK::DEBUG-IN-EMACS #<SIMPLE-ERROR {1002E3A1A1}>)<br> 2: ((LAMBDA (SWANK-BACKEND::HOOK SWANK-BACKEND::FUN)) #<FUNCTION SWANK:SWANK-DEBUGGER-HOOK> #<CLOSURE (LAMBDA #) {1002E3A9D9}>)<br>
3: (SWANK::CALL-WITH-REDIRECTED-IO #<SWANK::CONNECTION {10037B86D1}> #<CLOSURE (LAMBDA #) {1002E3A9F9}>)<br> 4: (SWANK::CALL-WITH-CONNECTION #<SWANK::CONNECTION {10037B86D1}> #<CLOSURE (LAMBDA #) {1002E3A9D9}>)<br>
5: (SWANK:INVOKE-SLIME-DEBUGGER #<SIMPLE-ERROR {1002E3A1A1}>)<br> 6: ((LAMBDA (SWANK-BACKEND::HOOK SWANK-BACKEND::FUN)) #<FUNCTION SWANK:SWANK-DEBUGGER-HOOK> #<CLOSURE (LAMBDA #) {1002E3A999}>)<br> 7: (INVOKE-DEBUGGER #<SIMPLE-ERROR {1002E3A1A1}>)<br>
8: (INVOKE-DEBUGGER #<SIMPLE-ERROR {1002E3A1A1}>)[:EXTERNAL]<br> 9: ((SB-PCL::FAST-METHOD HUNCHENTOOT:MAYBE-INVOKE-DEBUGGER (T)) #<unavailable argument> #<unavailable argument> #<SIMPLE-ERROR {1002E3A1A1}>)<br>
10: (SIGNAL #<SIMPLE-ERROR {1002E3A1A1}>)[:EXTERNAL]<br> 11: (ERROR #<SIMPLE-ERROR {1002E3A1A1}>)[:EXTERNAL]<br> 12: ((FLET #:LAMBDA43) #<SIMPLE-ERROR {1002E3A1A1}>)<br> 13: ((FLET #:LAMBDA43) #<SIMPLE-ERROR {1002E3A1A1}>)[:EXTERNAL]<br>
14: (SIGNAL #<SIMPLE-ERROR {1002E3A1A1}>)[:EXTERNAL]<br> 15: (ERROR "~@<There is no applicable method for the generic function ~2I~_~S~\n ~I~_when called with arguments ~2I~_~S.~:>")[:EXTERNAL]<br>
Locals:<br> SB-DEBUG::ARG-0 = 3<br> SB-DEBUG::ARG-1 = "~@<There is no applicable method for the generic function ~2I~_~S~\n ..<br> 16: ((SB-PCL::FAST-METHOD NO-APPLICABLE-METHOD (T)) #<unavailable argument> #<unavailable argument> #<STANDARD-GENERIC-FUNCTION ELEPHANT:GET-VALUE (3)>)[:EXTERNAL]<br>
Locals:<br> SB-DEBUG::ARG-0 = 5<br> SB-DEBUG::ARG-1 = :<NOT-AVAILABLE><br> SB-DEBUG::ARG-2 = :<NOT-AVAILABLE><br> SB-DEBUG::ARG-3 = #<STANDARD-GENERIC-FUNCTION ELEPHANT:GET-VALUE (3)><br>
17: (ELEPHANT::ENSURE-SLOT-DEF-INDEX #<unavailable argument> #<unavailable argument>)<br> Locals:<br> SB-DEBUG::ARG-0 = :<NOT-AVAILABLE><br> SB-DEBUG::ARG-1 = :<NOT-AVAILABLE><br>
18: ((SB-PCL::FAST-METHOD ELEPHANT:FIND-INVERTED-INDEX (ELEPHANT:PERSISTENT-METACLASS T)) #<unavailable argument> #<unavailable argument> #<unavailable argument> #<unavailable argument>)[:EXTERNAL]<br>
Locals:<br> SB-DEBUG::ARG-0 = :<NOT-AVAILABLE><br> SB-DEBUG::ARG-1 = :<NOT-AVAILABLE><br> SB-DEBUG::ARG-2 = :<NOT-AVAILABLE><br> SB-DEBUG::ARG-3 = :<NOT-AVAILABLE><br>
SB-DEBUG::ARG-4 = :<NOT-AVAILABLE><br> 19: (ELEPHANT:MAP-INVERTED-INDEX #<unavailable argument> #<unavailable argument> #<unavailable argument>)[:EXTERNAL]<br> Locals:<br> SB-DEBUG::ARG-0 = :<NOT-AVAILABLE><br>
SB-DEBUG::ARG-1 = :<NOT-AVAILABLE><br> SB-DEBUG::ARG-2 = :<NOT-AVAILABLE><br> SB-DEBUG::ARG-3 = :<NOT-AVAILABLE><br> 20: (FASHION-ORIGAMI::INIT-DUMMY-ITEM)<br> Locals:<br> #:G137 = :<NOT-AVAILABLE><br>
ANAPHORA:IT = :<NOT-AVAILABLE><br><br><br><br>