bmads_51

bmads_51

Web Development with Clojure, Third Edition: guestbook.auth functions not invocable (P. 168)

Dmitri Sotnikov @dmitri and Scot Brown @svmbrown

I was trying to execute the following code on p. 168:

user> (in-ns 'guestbook.auth)
#namespace[guestbook.auth]
guestbook.auth> (create-user! “testuser” “testpass”)
1
guestbook.auth> (authenticate-user “testuser” “testpass”)
{:login “testuser”, :created_at #inst “2019-09-20T02:22:53.217-00:00”}
guestbook.auth> (authenticate-user “testuser” “wrongpass”)

but the functions in the guestbook.auth namespace were simply unavailable after I switched to that namespace. I was getting No such var error messages.

After a lot of searching, I stumbled upon this from https://clojure.org/guides/repl/navigating_namespaces

How to make sure a lib is loaded

To make sure that a lib with namespace mylib.ns1 has been loaded in the REPL, you can do any one of the following:

  1. require it directly: (require '[mylib.ns1])
  2. load a namespace which itself requires mylib.ns1 (directly or indirectly).
  3. evaluate manually all the code in the source file mylib.ns1

So I believe this section in the book was too premature. I actually went on to type in the login route code further down on pp. 168-9. Since that login route code loads (a la #2 above) the guestbook.auth namespace, once you jack-in or lein repl you will be able to execute the functions in the guestbook.auth namespace. So I think if the code blocks are reversed, that would help solve this issue.

Popular Prag Prog topics Top

johnp
Running the examples in chapter 5 c under pytest 5.4.1 causes an AttributeError: ‘module’ object has no attribute ‘config’. In particula...
New
jamis
The following is cross-posted from the original Ray Tracer Challenge forum, from a post by garfieldnate. I’m cross-posting it so that the...
New
sdmoralesma
Title: Web Development with Clojure, Third Edition - migrations/create not working: p159 When I execute the command: user=> (create-...
New
rmurray10127
Title: Intuitive Python: docker run… denied error (page 2) Attempted to run the docker command in both CLI and Powershell PS C:\Users\r...
New
jeremyhuiskamp
Title: Web Development with Clojure, Third Edition, vB17.0 (p9) The create table guestbook syntax suggested doesn’t seem to be accepted ...
New
curtosis
Running mix deps.get in the sensor_hub directory fails with the following error: ** (Mix) No SSH public keys found in ~/.ssh. An ssh aut...
New
jskubick
I’m running Android Studio “Arctic Fox” 2020.3.1 Patch 2, and I’m embarrassed to admit that I only made it to page 8 before running into ...
New
akraut
The markup used to display the uploaded image results in a Phoenix.LiveView.HTMLTokenizer.ParseError error. lib/pento_web/live/product_l...
New
gorkaio
root_layout: {PentoWeb.LayoutView, :root}, This results in the following following error: no “root” html template defined for PentoWeb...
New
roadbike
From page 13: On Python 3.7, you can install the libraries with pip by running these commands inside a Python venv using Visual Studio ...
New

Other popular topics Top

Devtalk
Hello Devtalk World! Please let us know a little about who you are and where you’re from :nerd_face:
New
malloryerik
Any thoughts on Svelte? Svelte is a radical new approach to building user interfaces. Whereas traditional frameworks like React and Vue...
New
brentjanderson
Bought the Moonlander mechanical keyboard. Cherry Brown MX switches. Arms and wrists have been hurting enough that it’s time I did someth...
New
foxtrottwist
Here’s our thread for the Keyboardio Atreus. It is a mechanical keyboard based on and a slight update of the original Atreus (Keyboardio ...
New
New
New
AstonJ
Was just curious to see if any were around, found this one: I got 51/100: Not sure if it was meant to buy I am sure at times the b...
New
PragmaticBookshelf
Author Spotlight Erin Dees @undees Welcome to our new author spotlight! We had the pleasure of chatting with Erin Dees, co-author of ...
New
New
New

Latest in PragProg

View all threads ❯