That did the trick. Thanks. Oh and I'll be careful on StackOverflow :)
- Brad On Mar 4, 12:51 pm, Dave Ray <[email protected]> wrote: > Brad, > > As Kevin points out, because the values in the property file go > through read-string, they're read as Clojure literals, symbols in this > case. One solution is to make the string values look like string > literals to the reader: > > host="foo.com" > port=2525 > user="me" > pass="pwd" > > Try that and never believe anything you read on StackOverflow :) > > Dave > > > > > > > > On Sun, Mar 4, 2012 at 10:23 AM, Brad Lucas <[email protected]> wrote: > > I'm using Postal (https://github.com/drewr/postal) and found something > > I don't know how to fix. > > > I have my application working fine if I have a var with my smtp > > properties created as follows: > > > (def smtp-original {:host "foo.com" > > :port 2525 > > :user "me" > > :pass "pwd" > > }) > > > Since I want to release my project for others I thought to modify it > > to read the smtp values from a Properties file. I used the routine > > from Dave Ray's answer on StackOverFlow (http://stackoverflow.com/a/ > > 7781443/406220). > > > ;; Load smtp information out of a file > > fromhttp://stackoverflow.com/a/7781443/406220 > > (defn load-props > > [file-name] > > (with-open [^java.io.Reader reader (clojure.java.io/reader file- > > name)] > > (let [props (java.util.Properties.)] > > (.load props reader) > > (into {} (for [[k v] props] [(keyword k) (read-string v)]))))) > > > This works well in that it returns a Map that looks just like the smtp- > > original when reading the following file. > > > host=foo.com > > port=2525 > > user=me > > pass=pwd > > > The trouble is when I run my app and it calls into Postal I get a > > java.lang.ClassCastException. > > > I notice that the smtp-original created with a def is a > > clojure.lang.PersistentHashMap while the return from load-props is a > > clojure.lang.PersistentArrayMap. > > > I looked into Postal but don't see why this matters. > > > So, I guess I have a few questions. > > > Can I convert the PersistentArrayMap to a PersistentHashMap? Is this > > the right way to go? > > Is load-props doing something unusual? It seems fine. > > Does anyone understand the internals of Postal? Why would it not work > > with the PersistentArrayMap? > > > Any ideas or pointers would be greatly appreciated. I'm looking to > > understand what is going on. > > > Thanks > > > -- > > 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 -- 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
