I would like 2 types of advice:

1.) an answer to this specific question

2.) advice on how one is suppose to debug mysteries likes this

I have a simple web app that serves some data (hopefully in JSON
format, but at the moment I will accept anything at all). The app uses
Ring and Moustache and outputs the data.

We start with a simple atom:

(def registry (atom {}))

We put some data in this atom. And then we output it. But I have had
great difficulty getting anything to appear on the screen. Assuming
the problem was with the fact the main sequence was lazy, I added in
doall everywhere it made sense. But I still can not get anything to
work:

(defn current-users [request]
  "The default action of this app. Add new users to the registry, and
delete the ones that are more than 15 seconds old"
  (let [this-users-params (:params request)
        final-map-for-output {}]
  (add-to-logged-in-registry this-users-params)
  (remove-old-registrants)
  (response (apply str (into {}
                             (doall
                              (map (fn [each-user-map]
                                     (doall
                                      (let [inner-details (second each-
user-map)]
                                        (assoc final-map-for-output
"username" (get inner-details "username" "nothing found for user"))
                                        (assoc final-map-for-output
"updated" (get inner-details "updated" "nothing found for updated"))
                                        final-map-for-output)))
                                   @registry)))))))

The various variations I have tried on this have either given me a
blank white page or:

{}

Nothing else.

I used to do simply:

  (response (apply str (doall @registry)))))

This worked fine. But it did not output valid JSON, so I wanted to
change the format. But I have not been able to get anything to appear
on screen.

Suggestions?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to