I see what you are doing with the validations and defining them in the init-modelcall. I think that's a good idea actually and like it better than my solution to putting the callbacks in the model namespace.
A couple of small things that I noticed when starting to play around with clj-record. In your example you have: (ns com.example.user) (clj-record.core/init-model) but when I do that I get the error: java.lang.ClassNotFoundException: clj-record.core When I add a require it clears it up like: (ns com.example.user (:require [clj-record.core :as cr.core])) (cr.core/init-model) I know this is picky, but in your clj-record.core/init-model function you have: (first (reverse (re-split #"\." (name (ns-name *ns*))))) and could be changed to: (last (re-split #"\." (name (ns-name *ns*)))) I look forward to seeing clj-record progress. Thanks John. On Mon, Dec 29, 2008 at 10:20 PM, John D. Hume <duelin.mark...@gmail.com>wrote: > > On Mon, Dec 29, 2008 at 7:15 PM, Brian Doyle <brianpdo...@gmail.com> > wrote: > > I noticed that in the init-model macro you are creating a 'defn table [] > > ...' function in the > > model namespace and was wondering why you didn't just make it a def > instead, > > since > > it doesn't take any args? > > That didn't occur to me. I do like the idea of all the functionality > being available directly on clj-record.core with model name as a first > argument in addition to being defined in the model namespace, so I > guess that's one reason. But the inference of table name from model > name should only be the default, so maybe it would be better to just > def it there and let clj-record.core look it up there if needed, > somewhat as you recommended doing for callbacks... > > > I have an idea for you with the callbacks like, before-create, > after-create, > > etc. In the > > all-models-metadata in the core.clj you could store the namespace in the > > hash > > associated with the model-name on setup. Then in the create function > > defined in > > the core.clj you could call the before-create function defined in the > model > > something > > like: > > > > (let-if [bc ('before-create (ns-publics <model-namespace>)] (bc > > attributes#)) > > That's interesting. It's basically the opposite of the way I did the > validation stuff, where you pass in validation functions and those get > stored away in metadata and aren't directly accessible. (Here > "metadata" is not used in the clojure.org/metadata sense of the word. > I've thought about using clojure metadata to store model info, but I > don't know what symbol or collection I'd attach it to.) I think I > prefer the validation approach, because those functions have a certain > job to do and shouldn't be sitting there cluttering the model > namespace. (On the other hand, it is awfully convenient to be able to > test those functions directly.) > > Thanks again for looking. If you or anyone else has further comments, > I'd like to hear them. > git clone git://github.com/duelinmarkers/clj-record.git > > -hume. > > -- > http://elhumidor.blogspot.com/ > > > > --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---