RESTAS:GENURL problems with interactive development

74 views
Skip to first unread message

Mark Evenson

unread,
Nov 16, 2012, 4:45:29 AM11/16/12
to res...@googlegroups.com
Thanks so much for RESTAS!  I'm a couple weeks into a reasonable-sized project where I find that RESTAS has met or exceeded my needs.

One of the things I have found productive has been a very interactive approach to working with routes.  Since RESTAS:DEFINE-ROUTE thunks down to a DEFUN, after

(restas:define-route index ("" :content-type "text/html")
  (who:with-html-output-to-string (out)
    (:html
     (:title "Main")
     (:body (:p "Main page")))))


I can see what will be output via a simple

cl-user> (index)
"<html><title>Main</title><body><p>Main page</p></body></html>"


By setting various HUNCHENTOOT and RESTAS specials, I can usually rapidly iterate to the desired results.

The one problem I have found with this methodology is with the RESTAS:GENURL call.  If I use the following

(restas:define-module #:foo)
(in-package #:foo)
(restas:define-route index ("" :content-type "text/html")
  (who:with-html-output-to-string (out)
    (:html
     (:title "Main")
     (:body (:p "Main page")
        (:p (restas:genurl 'index))))))


then I get the following error when trying to invoke INDEX from the REPL:

There is no applicable method for the generic function
  #<COMMON-LISP:STANDARD-GENERIC-FUNCTION
    RESTAS:SUBMODULE-BASEURL (1)>
when called with arguments
  (COMMON-LISP:NIL).
   [Condition of type COMMON-LISP:SIMPLE-ERROR]

Restarts:
 0: [RETRY] Retry calling the generic function.
 1: [RETRY] Retry SLIME REPL evaluation request.
 2: [*ABORT] Return to SLIME's top level.
 3: [ABORT] Abort thread (#<THREAD "repl-thread" RUNNING {1003378063}>)

Backtrace:
  0: ((SB-PCL::FAST-METHOD COMMON-LISP:NO-APPLICABLE-METHOD (COMMON-LISP:T)) #<unused argument> #<unused argument> #<COMMON-LISP:STANDARD-GENERIC-FUNCTION RESTAS:SUBMODULE-BASEURL (1)> COMMON-LISP:NIL)
  1: (SB-PCL::CALL-NO-APPLICABLE-METHOD #<COMMON-LISP:STANDARD-GENERIC-FUNCTION RESTAS:SUBMODULE-BASEURL (1)> (COMMON-LISP:NIL))
  2: (RESTAS::SUBMODULE-FULL-BASEURL COMMON-LISP:NIL)
  3: (RESTAS:GENURL INDEX)
  4: (INDEX)

Is my usage pattern "just not going to work" as my code gets more sophisticated?  Is there some sort of additional special that I should bind when invoking routes from the REPL?  Would this go away if I used submodules? 

Thanks again for RESTAS,
Mark

Andrey Moskvitin

unread,
Dec 27, 2012, 7:04:00 AM12/27/12
to res...@googlegroups.com
Hi,

I'm sorry I did not answer for a long time.

I know about this problem and I have in mind is a interesting solution.
Maybe It will implement soon enough.

Andrey

2012/11/16 Mark Evenson <evenson...@gmail.com>:

Mark Evenson

unread,
Apr 23, 2014, 3:24:07 AM4/23/14
to res...@googlegroups.com


On Thursday, December 27, 2012 1:04:00 PM UTC+1, archimag wrote:
Hi,

I'm sorry I did not answer for a long time.

I know about this problem and  I have in mind is a interesting solution.
Maybe It will implement soon enough.

Any progress on this?

With a project using many (well, currently four) RESTAS modules for API composition, I find myself needing to write tests that need the value computed with GENURL for the current value of the mounts.

An example of a backtrace for using GENURL in a test:

The value NIL is not of type HASH-TABLE.
   [Condition of type TYPE-ERROR]

Restarts:
 0: [RETRY] Retry SLIME REPL evaluation request.
 1: [*ABORT] Return to SLIME's top level.
 2: [ABORT] Abort thread.

Backtrace:
  0: (#<FUNCTION {7C8CFC40}> #<TYPE-ERROR {1CB45231}> #<FUNCTION {7C8CFC40}>)
  1: (APPLY #<FUNCTION {7C8CFC40}> (#<TYPE-ERROR {1CB45231}> #<FUNCTION {7C8CFC40}>))
  2: (SYSTEM::RUN-HOOK SYSTEM::*INVOKE-DEBUGGER-HOOK* #<TYPE-ERROR {1CB45231}> #<FUNCTION {7C8CFC40}>)
  3: (INVOKE-DEBUGGER #<TYPE-ERROR {1CB45231}>)
  4: org.armedbear.lisp.Lisp.error(Lisp.java:382)
  5: org.armedbear.lisp.Lisp.type_error(Lisp.java:435)
  6: org.armedbear.lisp.HashTableFunctions.checkHashTable(HashTableFunctions.java:437)
  7: org.armedbear.lisp.HashTableFunctions$pf_gethash.execute(HashTableFunctions.java:127)
  8: org.armedbear.lisp.Symbol.execute(Symbol.java:814)
  9: org.armedbear.lisp.LispThread.execute(LispThread.java:832)
 10: org.armedbear.lisp.route_TMP_35.execute(route.lisp:150)
 11: org.armedbear.lisp.Symbol.execute(Symbol.java:803)
 12: org.armedbear.lisp.LispThread.execute(LispThread.java:814)
 13: org.armedbear.lisp.route_TMP_43.execute(route.lisp:182)
 14: org.armedbear.lisp.clos_303.execute(clos.lisp:2620)
 15: org.armedbear.lisp.LispThread.execute(LispThread.java:814)
 16: org.armedbear.lisp.clos_292.execute(clos.lisp:2527)
 17: org.armedbear.lisp.Symbol.execute(Symbol.java:814)
 18: org.armedbear.lisp.clos_277.execute(clos.lisp:2301)
 19: org.armedbear.lisp.FuncallableStandardObject.execute(FuncallableStandardObject.java:109)
 20: org.armedbear.lisp.Symbol.execute(Symbol.java:814)
 21: org.armedbear.lisp.LispThread.execute(LispThread.java:832)
 22: org.armedbear.lisp.route_TMP_46.execute(route.lisp:190)
 23: org.armedbear.lisp.CompiledClosure.execute(CompiledClosure.java:121)
 24: org.armedbear.lisp.LispThread.execute(LispThread.java:851)
 25: org.armedbear.lisp.Lisp.evalCall(Lisp.java:589)
 26: org.armedbear.lisp.Lisp.eval(Lisp.java:540)
 27: org.armedbear.lisp.Lisp.evalCall(Lisp.java:570)
 28: org.armedbear.lisp.Lisp.eval(Lisp.java:540)
 29: org.armedbear.lisp.Lisp.evalCall(Lisp.java:570)
 30: org.armedbear.lisp.Lisp.eval(Lisp.java:540)
 31: org.armedbear.lisp.SpecialOperators._let(SpecialOperators.java:146)
 32: org.armedbear.lisp.SpecialOperators$sf_let_star.execute(SpecialOperators.java:118)
 33: org.armedbear.lisp.Lisp.eval(Lisp.java:530)
 34: org.armedbear.lisp.Lisp.progn(Lisp.java:709)
 35: org.armedbear.lisp.Primitives$sf_block.execute(Primitives.java:3742)
 36: (GETHASH :TEMPLATE NIL)
 37: (RESTAS::ROUTE-SYMBOL-TEMPLATE BROKER.SDM.BUFFALO.EDU::-QR-.%GET-QR)
 38: (#<FUNCTION {5F6878B0}> (BROKER.SDM.BUFFALO.EDU::-QR-.%GET-QR (:QR "/personid/858923/accountnumber/518200/lastname/Bear/chartnumber/200000/firstname/Ann/middlename/I")))
 39: (RESTAS:MAKE-ROUTE-URL BROKER.SDM.BUFFALO.EDU::-QR-.%GET-QR (:QR "/personid/858923/accountnumber/518200/lastname/Bear/chartnumber/200000/firstname/Ann/middlename/I"))
 40: (RESTAS:GENURL BROKER.SDM.BUFFALO.EDU::-QR-.%GET-QR :QR "/personid/858923/accountnumber/518200/lastname/Bear/chartnumber/200000/firstname/Ann/middlename/I")

Reply all
Reply to author
Forward
0 new messages