The macros indexed by this gist https://gist.github.com/1177043 (copied and pasted below)
(defmacro wrap-connection [& body] `(if (sql/find-connection) ~@body (sql/with-connection db ~@body))) (defmacro transaction [& body] `(if (sql/find-connection) (sql/transaction ~@body) (sql/with-connection db (sql/transaction ~@body))))
appear to become pretty helpful. It is possible to "standard" implementation of those? By standard, I am talking about something in clojure.contrib or similar. I'm able to easily copy this into my code, but I am wondering if there's an easy method. Or, put one other way, what is the clojure method of carrying this out?
This really is my first forray into really writing clojure code (I have read a great deal about this and customary Lisp), so I am also looking to get an understanding for which libraries are available. It appears in my experience the Lisp attitude is type of "I'm able to write it myself in 15 lines, kind I personally use another woman'sInch.
From what I've come across, whenever you abstract beyond
sql/transactions etc then your abstractions tend to be application specific. writing your personal wrappers as above if this actually makes things simpler may be the canonical approach to take about things.
Just use as numerous macroes as really makes your existence simpler, it may be tempting to next macroes (as with the gist) with techniques which are more confusing or harder to keep. I love this gist just take care not to over-macro.
ps: if some code is much more than about five lines I turn to find out if another person has written it first :) however, many clojurians feel in a different way.