On Feb 3, 3:55 pm, Mark McGranaghan <[email protected]> wrote: > One thing that would help us a lot with choosing the right interface > for sessions is examples of session use from real application code. We > have considered simple examples like incrementing a counter and > logging in / logging out (http://gist.github.com/289993), but a > concrete example of read-write-read session usage would be really > helpful. Would you be willing to show us a case were you think > stateful sessions would be particularly nice?
There were a few corner cases with immutable sessions discussed in compojure group: Invalidating sessions do not work. James replied that it would be hard to fix with immutable sessions: http://groups.google.com/group/compojure/browse_thread/thread/b27ab40d6ebb8864/4ef387a8d0788b49 Another one is that (session-assoc) silently fails if you run it more than once: http://groups.google.com/group/compojure/browse_thread/thread/4b7c1734d2eb9fde/c584cc942ef4364d?q=#c584cc942ef4364d Solution is.. not to run it more than once. :)) But imagine chained function calls. Those session-assocs will clash. > It is possible to communicate between purely functional middleware > layers. The way one does this is by assoc'ing keys into the request > and/or response maps, and then get'ing and acting on those values > later in the request/response ring [1]. Ah my bad. I shouldn't have said "impossible". Obviously it is possible, because i do that too. But it feels like a kludge. Sometimes you return body of html. Other times you have to return response object where body is one of its value-key parts along with some other keys. >Would this kind of > communication be helpful for the problems that you are having? Again, > specific examples would be great. > Here's the problem i am having with passing a session: Session is a long term data storage. This means that it should be available be read / write from anywhere in the chain of processing the request. In haskell you can pass session through a chain of functions in a State monad. Any function in a chain can read or write thus affecting others. If we can achieve same thing in compojure it would be great, not because it is not possible to operate other way. But because it would be much more simpler. BTW i do not see any point in trying to make session handling "pure". We are dealing with fundamentally impure operation: handling a web request. It practically always depends on more than input variables. If it is a static file it depends on what's on the harddrive. Most cases it reads/writes data to database. In fact, if not the performance price for hitting database, no one would bother with sessions. It is quite simple to store session data in database. The reason we are holding that data in a session is not that it is somehow different from other data that we store in db. The reason is that we need that data in every request. We simply caching. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en
