libera/#lisp - IRC Chatlog
Search
17:17:02
serafeim
is there a way to test a hunchentoot acceptor? for example, i've modified my acceptor so it adds some variables in the session. how can i test that functionality ?
17:24:31
serafeim
yes i know i could do the http requests by hand however i'd was wondering if there was a better way to test it; i.e with a fake client that would run the tests and have access to *request* and *session* directly
17:25:50
Bubblegumdrop
https://github.com/edicl/hunchentoot/blob/master/test/script.lisp That is essentially what the built in test suite does. I don't know about accessing *request* or *ession*
17:26:57
serafeim
Bubblegumdrop: yeah i saw that but it ain't what i had in mind :( to understand what I mean: https://docs.djangoproject.com/en/5.1/topics/testing/tools/#the-test-client
17:28:23
Bubblegumdrop
https://github.com/edicl/hunchentoot/blob/master/test/script-engine.lisp#L161
17:30:26
serafeim
Bubblegumdrop: yes i've heard of it but i'd prefer to avoid too much external libs
17:40:15
serafeim
f.e i've got this function that logs in a user https://dpaste.com/EHM8MKZ9N ; there's no real way to test it
17:42:18
Bubblegumdrop
I'm using caveman but perhaps you can translate a similar idea to hunchentoot https://git.lain.church/Bubblegumdrop/cl-deck-builder2/src/branch/master/src/web/toolkit.lisp#L21
17:44:32
Bubblegumdrop
That way, you can just wrap your routes that require a login with WITH-LOGGED-IN-USER
17:44:51
serafeim
however i was thinking of using the easyroot-decorators https://github.com/mmontone/easy-routes?tab=readme-ov-file#decorators to ensure that routes would get a logged in user
17:44:53
Bubblegumdrop
And if the login was successful, you can expect the appropriate output, or an HTTP redirect to a login page otherwise
17:46:23
Bubblegumdrop
The freedom to do whatever you please however you please to do it can be an obstacle sometimes.
17:47:24
Bubblegumdrop
The best course of action in this case is to just mash out random sh*t. Writing helps your brain coalesce ideas into something coherent.
17:47:48
Bubblegumdrop
What are your thoughts on ChatGPT? It's quite helpful in situations like this I've found as well.
17:48:37
serafeim
hm i don't have very good experience with copilot... i'm using claude.ai and chaptgpt both sometimes
17:48:51
Bubblegumdrop
I've only recently signed up with Claude so I haven't formed an opinion on it yet
17:49:05
Bubblegumdrop
ChatGPT is amazing at writing prose and my lisp comes across like prose so it's been 11/10 IME
17:49:09
Lumie
Bubblegumdrop: I don't really use it for Lisp but I have gotten good results for LaTeX
17:49:13
serafeim
what is *very* useful to me is that I can copy paste a bootstrap 5 html snippet and ask it to return it to me to spinneret. it works perfectly every time and is very helpful
17:49:47
Bubblegumdrop
You can give it a psuedo-code description of what you want and it will do a pretty good job too.
17:50:23
Bubblegumdrop
have you tried djula? Its one of caveman's dependencies https://github.com/mmontone/djula
17:55:00
serafeim
hm well i am using django for like 15 years so i'd wanted something different for templates
18:37:41
wasamasa
like, the case for macros is a bit of convenience and maybe faster templating speed, but when's the last time that was your bottleneck?
19:20:23
Bubblegumdrop
That was a pretty common source of frustration for me. I hadn't figured out a solution yet.
19:48:27
serafeim
i'm a little troubled with the hunchentoot multi-thread situation. i see that there's a `(defvar-unbound *request*)` in hunchentoot. this global will be set to be the current request. but what would happen if there are multiple threads ? won't their requests be mixed?
19:49:04
serafeim
i asked claude.ai and it answered me this: Special variables in Common Lisp: In Common Lisp, special variables (like *request*) have dynamic scope. This means their bindings are thread-local by default. ; is this true ?
19:49:43
robin
serafeim, it'll be implementation-dependent, but iirc yes special variables end up being thread-local
19:51:06
robin
serafeim, i think sbcl for example will "inherit" the initial thread-local value from the creator thread, which may be the reason for "defvar-unbound" (whatever that does -- just a special declamation?)
19:51:46
serafeim
it says: "Convenience macro to declare unbound special variables with a documentation string."
19:55:12
Bubblegumdrop
Thanks whoever mentioned clisp, I never thought I'd be trying different CL implementations
20:26:12
owen
the only reason a user would touch hiccl::render-form is to specialize on a class or something for a special case
20:34:49
kagevf
owen: cool, I will check out hccl more at some point ... I like cl-who, but I can't figure out how to get it handle markup at runtime - such as from user input - without using eval ...
20:36:40
paulapatience
owen: Sure, but if the usecase of specializing to a class is meant to be allowed for users, the function should be exported.