Re: Clojure Login form error: java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to clojure.lang.Atom

2013-05-02 Thread David Toomey


On May 2, 7:59 am, "John D. Hume"  wrote:
> I've never used noir and have barely used 4clojure, but both of them
> apparently do hidden global things that make it hard to know the context in
> which your code is running. Your app needs to be wrapped in noir's
> `wrap-noir-session` middleware in much the same way this blog post shows
> Ring's `wrap-session` being used:
>
> http://rjevans.net/post/2628238502/session-support-in-compojure-ringhttps://gist.github.com/mirrormatch/768768
>
> I'll leave it at that.

Cool, thanks.

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Clojure Login form error: java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to clojure.lang.Atom

2013-05-02 Thread gaz jones
>> Does the projects look like the work of someone that is an utter moron

... your response certainly is.


On Thu, May 2, 2013 at 10:28 AM, Jay Fields  wrote:

> On Thursday, May 2, 2013 10:19:51 AM UTC-4, David Toomey wrote:
>
>>
>> [snipped]
>
>
> If you want help in the future, I'd recommend spending less time demanding
> answers and more time reading responses and code.
>
> I've never looked at the 4clojure source, didn't even know it was on
> github. I've never used ring, compojure, or any other clojure web
> framework. The total time it took me to clone the 4clojure repo, grep for
> what John recommended, and get you this link (
> https://github.com/4clojure/4clojure/blob/develop/src/foreclojure/core.clj#L58),
> about 30 seconds.
>
> Python has been around significantly longer, and has a much larger
> community. If you need that level of support, I don't think Clojure is the
> right language for you.
>
> Cheers, Jay
>
> --
> --
> 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Clojure Login form error: java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to clojure.lang.Atom

2013-05-02 Thread Jay Fields
On Thursday, May 2, 2013 10:19:51 AM UTC-4, David Toomey wrote:

>
> [snipped]


If you want help in the future, I'd recommend spending less time demanding 
answers and more time reading responses and code.

I've never looked at the 4clojure source, didn't even know it was on 
github. I've never used ring, compojure, or any other clojure web 
framework. The total time it took me to clone the 4clojure repo, grep for 
what John recommended, and get you this link (
https://github.com/4clojure/4clojure/blob/develop/src/foreclojure/core.clj#L58),
 
about 30 seconds.

Python has been around significantly longer, and has a much larger 
community. If you need that level of support, I don't think Clojure is the 
right language for you.

Cheers, Jay

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Clojure Login form error: java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to clojure.lang.Atom

2013-05-02 Thread John D. Hume
I've never used noir and have barely used 4clojure, but both of them
apparently do hidden global things that make it hard to know the context in
which your code is running. Your app needs to be wrapped in noir's
`wrap-noir-session` middleware in much the same way this blog post shows
Ring's `wrap-session` being used:

http://rjevans.net/post/2628238502/session-support-in-compojure-ring
https://gist.github.com/mirrormatch/768768

I'll leave it at that.

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Clojure Login form error: java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to clojure.lang.Atom

2013-05-02 Thread David Toomey


On May 2, 5:21 am, "John D. Hume"  wrote:
> On May 2, 2013 2:04 AM, "David Toomey"  wrote:
>
> > Is there anything
> > I could show that could reveal the problem?
>
> Yes, you should have shown the stack trace of the exception (or at least
> the part from the top of the text down to your code).
>
> But even without that, you have an error coming out of noir.session that
> says something is unbound where an atom was expected. That should send you
> to the source for noir.session. There you'll see everything depends on the
> dynamic global *noir-session*, which is only ever bound by
> wrap-noir-session, which you're not calling. That's a compojure middleware
> fn. Take a look at some compojure tutorial to see where and how they're
> used.
>
> There are likely other similar middleware fn calls noir will expect you to
> have made. Hopefully having struggled with this one, figuring the others
> out will be easy.

Wow. What an amazing answer.

The stack trace: The main error is the title of this thread. The
second line is something about swap! and clojure.core, the next line
traces directly to the line of code that I pointed out 2 times above.
The next line after that points to a route, which I posted above as
well.

Here is the login code from 4clojure: what "middleware" and what call
to wrap-noir-session is being used here?

(defn do-login [user pwd]
  (let [user (.toLowerCase user)
{db-pwd :pwd} (from-mongo (fetch-one :users :where {:user
user}))
location (session/get :login-to)]
(if (and db-pwd (.checkPassword (StrongPasswordEncryptor.) pwd
db-pwd))
  (do (update! :users {:user user}
   {:$set {:last-login (java.util.Date.)}}
:upsert false) ; never create new users
accidentally
  (session/put! :user user)
  (session/remove! :login-to)
  (response/redirect (or location "/problems")))
  (flash-error "/login" "Error logging in."

Clearly, there is none.

Then you give me a total fuck you answer, "Hopefully having struggled
with this one, figuring the others out will be easy."

How is that at all helpful? You tell me to look at the Lib-Noir source
and the source says exactly what I already knew (because, clearly you
are psychic and you know that I didn't look already). Wait... do you
want me to ask Google for a Clojure login page tutorial? Done, do you
know what the first several hits are? My blog which explains how to do
it in Noir. The next few are Stack Overflow threads asking about
creating login pages and this very topic:

This thread, with 4 upvotes is unanswered:
http://stackoverflow.com/questions/14806063/howto-use-lib-noir-stateful-sessions-in-compojure

Four upvotes is quite a lot for a Clojure question. This probably
indicates that this is a broad issue that affects many people. Why?
Because of this shit right here. Clojure is a beautiful language, but
these kind of LOL answers are exactly why the community sucks (I've
read and heard more that a few disturbing complaints) and why people
don't want to learn the language, which is further exacerbated by the
sub-optimal documentation and don't even get me started on the half-
assed tutorials ("Look at WHAT middleware tutorial?). If a person just
coming to Clojure is struggling to create something incredibly basic
(hell, IDK, a login page?) and when asked, can't get a civil response,
then the language is toast.

I linked to my github. Does the projects look like the work of someone
that is an utter moron at this language or Lisp in general?

Let me take this moment to help you: the correct way to answer the
question is to direct me to a *reputable* source that touches on this
issue, and maybe just maybe accept the retarded idea that I showed you
EXACTLY where the stacktraces pointed (which I did). If all else
fails, you can even tell me the answer or at least try to answer it in
a way that isn't utterly condescending or act like you can't look at 5
LOC and not comprehend that "error on this line" means "error on
this line." Clearly, I don't see what the issue is and I am asking for
help to see where my logic is wrong: I'm not asking you to be an ass.

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Clojure Login form error: java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to clojure.lang.Atom

2013-05-02 Thread John D. Hume
On May 2, 2013 2:04 AM, "David Toomey"  wrote:
> Is there anything
> I could show that could reveal the problem?

Yes, you should have shown the stack trace of the exception (or at least
the part from the top of the text down to your code).

But even without that, you have an error coming out of noir.session that
says something is unbound where an atom was expected. That should send you
to the source for noir.session. There you'll see everything depends on the
dynamic global *noir-session*, which is only ever bound by
wrap-noir-session, which you're not calling. That's a compojure middleware
fn. Take a look at some compojure tutorial to see where and how they're
used.

There are likely other similar middleware fn calls noir will expect you to
have made. Hopefully having struggled with this one, figuring the others
out will be easy.

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Clojure Login form error: java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to clojure.lang.Atom

2013-05-02 Thread David Toomey
I committed the codebase to github. I'm open-sourcing the whole
project anyways, so here is what I have thus far. Since I'm stuck at
the login, the conversion stops there, so this isn't the complete
codebase and basically still a skeleton:

https://github.com/dt1/SoloResume

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Clojure Login form error: java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to clojure.lang.Atom

2013-05-02 Thread David Toomey
Is this serious? No one knows how to create a login form in Compojure?
I'm seriously confused. I can create accounts, but I can't get the
login part to work. What could I possibly be doing wrong? Is there
anything in my code that indicates something wrong? Is there anything
I could show that could reveal the problem?

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Clojure Login form error: java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to clojure.lang.Atom

2013-04-30 Thread David Toomey
To clarify, I was suspecting that I did something wrong in the (POST)
route. I tried using (:syms) as well as (:strs). I'm really stuck on
what is happening here.

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Clojure Login form error: java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to clojure.lang.Atom

2013-04-30 Thread David Toomey


On Tuesday, April 30, 2013 6:25:11 AM UTC-7, Tassilo Horn wrote:
>
> David Toomey > writes: 
>
> Hi David, 
>
> > The error, as mentioned in the title: java.lang.ClassCastException: 
> > clojure.lang.Var$Unbound cannot be cast to clojure.lang.Atom 
>
> In which line? 
>
> The error is where the bolded is. It may have been confusing on the OP 
because I accidentally posted the test-case on not the real code: 

(defn do-login [handle passwd]
  (let [tuser (select db/allusers
  (fields :username :password :usertype)
  (where {:username handle}))]
(if (crypt/compare passwd
   (let [[{pwd :password}] tuser]
 pwd))
  ;ERROR:
  (do *(sesh/put! :uname handle)*
  (response/redirect "/"))
  (response/redirect "/"
 

> Hm, the message tells that you are using an atom function like swap! on 
> something that's not an Atom but Unbound.  But your code doesn't contain 
> such a coll.  So I guess it's in the SQL Korma code here 
> where db/allusers is Unbound. 
>
>
No, that part and the bcrypt comparision passes. Regardless, Korma does not 
use atoms. The problem is with the noir.session namespace and the error 
revolves around (sesh/put!). As I understand it, the noir.session namespace 
uses an atom. 


-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Clojure Login form error: java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to clojure.lang.Atom

2013-04-30 Thread Tassilo Horn
David Toomey  writes:

Hi David,

> The error, as mentioned in the title: java.lang.ClassCastException:
> clojure.lang.Var$Unbound cannot be cast to clojure.lang.Atom

In which line?

Hm, the message tells that you are using an atom function like swap! on
something that's not an Atom but Unbound.  But your code doesn't contain
such a coll.  So I guess it's in the SQL Korma code here

>   (let [tuser (select db/allusers
>   (fields :username :password :usertype)
>   (where {:username "newguy"}))]

where db/allusers is Unbound.

Bye,
Tassilo

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Clojure Login form error: java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to clojure.lang.Atom

2013-04-30 Thread David Toomey
Hello, I am trying to get a login form to work in Compojure. I had 
originally written this app in Noir, but now I'm trying to move it off of 
Noir. I am now using Lib-Noir and the (noir.session) namespace doesn't seem 
to be working the same way as Noir. I'm now confused. 

The error, as mentioned in the title: 
java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to 
clojure.lang.Atom


Here is the code that appears to be getting mucked up: 

(defn do-login [handle passwd]
  (let [tuser (select db/allusers
  (fields :username :password :usertype)
  (where {:username "newguy"}))]
(if (crypt/compare "password" 
   (let [[{pwd :password}] tuser]
 pwd))
  ;; error on this line: 
  (do (sesh/put! :uname handle)
  (response/redirect "/"))
  (response/redirect "/"

and the route:

  (GET "/account-login" [] (homes/login-page))
  (POST "/account-login" {{:strs [handle passwd]} :params}
(log/do-login handle passwd))

Basically, except for the silly let-binding above, I'm following the 
pattern found in 4clojure. 



-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.