Re: sessions in Ring, Sandbar, Compojure, etc...

2011-07-26 Thread Shree Mulay
Dear Brenton, James, et al., The problem what the (wrap-reload) function that I was using in my code, which isn't necessary anymore as ring, by default, includes the functionality now (I think???). http://mmcgrana.github.com/ring/middleware.reload-api.html Brenton, I was wondering if there's a

Re: sessions in Ring, Sandbar, Compojure, etc...

2011-07-26 Thread Shree Mulay
On Saturday, May 14, 2011 4:48:03 PM UTC-4, James Reeves wrote: > > On 14 May 2011 20:49, Shree Mulay wrote: > > One final thought I had is I've noticed if I reload a page, the > > session information is lost. How do we get around this? > > You could use defonce to define an atom to back the sessi

Re: sessions in Ring, Sandbar, Compojure, etc...

2011-05-14 Thread James Reeves
On 14 May 2011 20:49, Shree Mulay wrote: > One final thought I had is I've noticed if I reload a page, the > session information is lost. How do we get around this? You could use defonce to define an atom to back the session storage. e.g. (require 'ring.middleware.session.memory) (defonce m

Re: sessions in Ring, Sandbar, Compojure, etc...

2011-05-14 Thread Shree Mulay
On May 12, 8:12 pm, James Reeves wrote: > On 13 May 2011 00:23, Shree Mulay wrote: > > > I didn't know there was? What I understood of wrap-reload is that I > > didn't have to restart "lein ring server" at the command line > > everytime I made a change to my core.clj file??? > > > How do I set up

Re: sessions in Ring, Sandbar, Compojure, etc...

2011-05-12 Thread James Reeves
On 13 May 2011 00:23, Shree Mulay wrote: > I didn't know there was? What I understood of wrap-reload is that I > didn't have to restart "lein ring server" at the command line > everytime I made a change to my core.clj file??? > > How do I set up lein-ring to give me the same functionality? lein-r

Re: sessions in Ring, Sandbar, Compojure, etc...

2011-05-12 Thread Shree Mulay
James, et al., > I'm not sure. There exist better alternatives to the `wrap-reload` > middleware anyway, such as the lein-ring plugin. > I didn't know there was? What I understood of wrap-reload is that I didn't have to restart "lein ring server" at the command line everytime I made a change to m

Re: sessions in Ring, Sandbar, Compojure, etc...

2011-05-12 Thread James Reeves
On 12 May 2011 20:37, Shree Mulay wrote: >  ;(wrap-reload '(SocialNetworkCore.core))  ;;remove wrap-reload > > it started behaving. Is the "wrap-reload" functionality not compatible > with Ring Sessions??? Have I implemented it the wrong way? I'm not sure. There exist better alternatives to the `

Re: sessions in Ring, Sandbar, Compojure, etc...

2011-05-12 Thread Shree Mulay
James, et al., WHOA! I got it to work! After I commented out ;(wrap-reload '(SocialNetworkCore.core))  ;;remove wrap-reload it started behaving. Is the "wrap-reload" functionality not compatible with Ring Sessions??? Have I implemented it the wrong way? Only thing is, when I goto http://127

Re: sessions in Ring, Sandbar, Compojure, etc...

2011-05-12 Thread Shree Mulay
@ James, yes. (def app (-> #'main-routes (wrap-reload '(SocialNetworkCore.core)) ;;remove wrap-reload from production code (wrap-params) ;; wraps params (inputs from forms) - makes 'em available ;(wrap-flash);; (wrap-session)

Re: sessions in Ring, Sandbar, Compojure, etc...

2011-05-12 Thread James Reeves
On 12 May 2011 04:49, Shree Mulay wrote: > But for WHATEVER reason, the sessions are NOT getting stored? Have you added the session middleware? e.g. (def app (-> main-routes wrap-params wrap-session)) Or more succinctly: (def app (handler/site main-routes)) - James -- You re

Re: sessions in Ring, Sandbar, Compojure, etc...

2011-05-11 Thread Shree Mulay
James, I even tried the examples you gave me: (defroutes main-routes (GET "/" [] (welcome)) (GET "/form" [] (render-form)) (GET "/login/" [] (login-view)) ; (POST "/login/" {request :request params :params} (login- controller request params)) (POST "/login/" {params :params sess

Re: sessions in Ring, Sandbar, Compojure, etc...

2011-05-11 Thread Shree Mulay
Aaron, et al., That didn't seem to make any difference. I believe the example I got "dosync" from wanted the whole thing to move forward as a transaction (???). Anyhow, this is what it looks like now: (defn login-controller [params session] (do (println (params "password") (params "name"))) (

Re: sessions in Ring, Sandbar, Compojure, etc...

2011-05-11 Thread Aaron Cohen
On Wed, May 11, 2011 at 10:27 PM, Shree Mulay wrote: > > ;;takes the input params from the login form and stores the > ;;logged in user into a session. You get logged in when the > ;;password value is = secret > (defn login-controller [params session] >  (do (println (params "password") (params "n

Re: sessions in Ring, Sandbar, Compojure, etc...

2011-05-11 Thread Shree Mulay
Thanks Brenton, I've gone through your example, and tried to replicate it at my end(for my use cases) but was unable to. I demoed most of the examples you've provided and they look GREAT! I hope that I'll be able to make projects work (and look) like the examples you've shared with us one day. Th

Re: sessions in Ring, Sandbar, Compojure, etc...

2011-05-11 Thread Shree Mulay
Dear Aaron, et al., I have been wrapping my sessions. Perhaps there's something I'm missing??? (def app (-> #'main-routes (wrap-reload '(SocialNetworkCore.core)) ;;remove wrap-reload from production code (wrap-params) ;; wraps params (inputs from forms) - makes

Re: sessions in Ring, Sandbar, Compojure, etc...

2011-05-11 Thread Shree Mulay
Dear James, et al., Here is what I'm trying to do: --- ;;Login form to login. To login successfully, let ;;password = secret (defn login-view [] (html [:p (form-to [:post "/login/" ] "User name: " [:input {:name "name", :type "te

Re: sessions in Ring, Sandbar, Compojure, etc...

2011-05-11 Thread Brenton
Shree, I would suggest that you try to use only Ring first. Once you get how it works, take a look at Sandbar and see if that may work better for you in specific situations. The session code in Sandbar is stable. It will not change much in the next release. In fact it may become its own project b

Re: sessions in Ring, Sandbar, Compojure, etc...

2011-05-11 Thread James Reeves
On 12 May 2011 00:04, Shree Mulay wrote: > From this code, I can't figure out where you "instantiate" the session > var, store to it, and read back from it? I know there's not > instantiation in clojure(???). I hope your able to get what I'm having > trouble figuring out. The session is read from

Re: sessions in Ring, Sandbar, Compojure, etc...

2011-05-11 Thread Aaron Cohen
The "magic" is in wrap-session, which adds the session middleware to your stack. At that point, your ring handler will see that it's request map has a new key (:session) which is a map containing all your session variables. You can assoc anything into that map and it will be stored in the session

Re: sessions in Ring, Sandbar, Compojure, etc...

2011-05-11 Thread Shree Mulay
Paul, I'm using ring, hiccup, compojure, and clutch (for my database connectivity via CouchDB). I'm avoiding Sandbar, cause I can't figure too much of it out anyways) at this point, at least. I think the only thing I'm using compojure for is [GET POST ANY defroutes]. I'm building the "core compo

Re: sessions in Ring, Sandbar, Compojure, etc...

2011-05-11 Thread Shree Mulay
James, >From this code, I can't figure out where you "instantiate" the session var, store to it, and read back from it? I know there's not instantiation in clojure(???). I hope your able to get what I'm having trouble figuring out. I'm not sure whether the magic happens here: (let [n (session :n

Re: sessions in Ring, Sandbar, Compojure, etc...

2011-05-11 Thread Paul Dorman
Hi Shree, while I wouldn't dare give you technical advice, I may have something to offer as a fellow Clojure noob. I did try Sandbar for my project, but found, as I delved deeper into the universe of Clojure web development, that I was altogether over-complicating everything. This, and the fact th

Re: sessions in Ring, Sandbar, Compojure, etc...

2011-05-11 Thread Shree Mulay
On May 10, 9:20 pm, Matthew Boston wrote: > Maybe try looking at the source of a project on github using logins/ > sessions.  One I'm currently using for reference is from > 4clojurehttps://github.com/dbyrne/4clojure > Hey Matthew, I'm looking at the code. If I can't get headway on Ring, I mi

Re: sessions in Ring, Sandbar, Compojure, etc...

2011-05-11 Thread Shree Mulay
> There's an example of Ring sessions linked from the Ring wiki: > > https://gist.github.com/608048 > > Does that help? > > - James On May 10, 6:19 am, James Reeves wrote: > On 10 May 2011 07:24, Shree Mulay wrote: > > > For the life of me, I can't get sessions to work, immaterial of which > >

Re: sessions in Ring, Sandbar, Compojure, etc...

2011-05-10 Thread Matthew Boston
Maybe try looking at the source of a project on github using logins/ sessions. One I'm currently using for reference is from 4clojure https://github.com/dbyrne/4clojure On May 10, 2:24 am, Shree Mulay wrote: > For the life of me, I can't get sessions to work, immaterial of which > tutorial I try

Re: sessions in Ring, Sandbar, Compojure, etc...

2011-05-10 Thread James Reeves
On 10 May 2011 07:24, Shree Mulay wrote: > For the life of me, I can't get sessions to work, immaterial of which > tutorial I try and get going???  Is there any tutorial out there that > explicitly explains everything for a newb like me? After several > round, I did successfully get form params to

sessions in Ring, Sandbar, Compojure, etc...

2011-05-09 Thread Shree Mulay
For the life of me, I can't get sessions to work, immaterial of which tutorial I try and get going??? Is there any tutorial out there that explicitly explains everything for a newb like me? After several round, I did successfully get form params to work! YEAH! But now, I'd like to create a login s