hi clojure-users,

i have a question regarding the setup and propagation
of config-params.

to configure a clojure-based web-app, i use a global var
*opts* that is setup like this:

(defn get-opts
  [environment]
  (condp = environment
    :development
      { :webapp-context "/mywebapp"
        :webapp-dir "src/main/webapp"
        :authentication true
        :show-sql true}
    :test
      { :webapp-context "/mywebapp"
        :webapp-dir "src/main/webapp"
        :authentication false
        :show-sql true}
    :production
      { :webapp-context "/mywebapp"
        :webapp-dir "/appserver/tomcat/apache-tomcat-5.5.25/webapps/
mywebapp"
        :authentication true
        :show-sql false}
    (throw (IllegalArgumentException. (str "unexpected environment: "
environment)))))

(def ^:dynamic *opts* (get-opts :development))


i run tests like this:

(binding [*opts* (get-opts :test)]
  (run-tests)))


references to *opts* are scattered all over my clojure-code
so that many of the functions are impure. this seems like
a smell to me and there are probably cleaner ways to propagate
config-params (keep functions pure) ... what are they ?

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

Reply via email to