Hi,

On 25 Mrz., 10:09, Thorsten Wilms <t...@freenet.de> wrote:

> Interesting, but you just listed title and body twice, where the goal
> was to not list them at all (except in the definition of Article and in
> the html form, of course, though theoretically, the form could be
> generated from a a bit richer single definition, I suppose).

Can you generate a "empty" article and set stuff with setters?
Then you could use reflection.

(defn save-article
  [path form-params timestamp]
  (let [article (Article.)]
    (doto article
      (.setPath path)
      (.setTimestamp timestamp))
    (doseq [[k v] form-params]
      (let [setter (.getMethod article (str "set" k))]
        (.invoke setter article v)))
    (ds/save! article)))

I don't know how the reflection API works, so just some pseudo
calls to get across the idea. And you probably shouldn't use
this in speed critical code.

Sincerely
Meikel

-- 
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