<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">Robert,<DIV><BR class="khtml-block-placeholder"></DIV><DIV>That's exactly what I was referring to, except that instead of using DCM, just use the standard persistence machinery in Elephant (for the main reason that I haven't learned your DCM yet :) ). Anyway, I guess as you guys get closer to integrating the DCM concept(s) into the standard machinery as we discussed a few weeks back, this would be a non-issue since you seem to have that (or similar) functionality already in place. Anyway, just food for thought.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Thanks,</DIV><DIV>Daniel</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><DIV><DIV>On Aug 11, 2006, at 5:40 PM, Robert L. Read wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite"> Just a quick comment on this --- Ian may have a better idea.<BR> <BR> Yes, if we offered a nice clean place to put all of those, it would make it obvious<BR> where to put validation.  (I will certainly think about that in the future.)<BR> <BR> Here is a technique that I use, that is very effective for me, but not generally <BR> applicable:  I use DCM, which is in the contrib directory and basically provides<BR> wrappers for the create/read/update/destory operations, similar to those you <BR> name below.  I use :after methods on these operations (specialized on Director<BR> classes, since it is generally class dependedent) to send objects to a text indexer<BR> in a background thread whenever they change.  (I was using Lucene-ws but now<BR> use montezuma; it makes sense to do these operations in a back-ground thread since<BR> a web-service call might block the thread that needs to get a response on to the <BR> glass as fast as possible.)<BR> <BR> This is an extraordinarily powerful and elegant feature of LISP.  If you have a method<BR> that gives you a "change point" (I believe that is what you are asking for) then you can<BR> easily put a :before method in a completely different file that performs validation and<BR> signals an exception or takes some other action that interrupts the intended operation.  <BR> One of the beauties of this is that the validation rules can be easily kept quite separate from the rest of the code.<BR> <BR> I suppose this same technique could be applied even if you do not have clearly defined<BR> methods; but personally I consider this clarity to be one of the advantages of the DCM code.<BR> Of course, one can more or less easily create your own validation points, without becoming<BR> dependeing on the DCM code.  <BR> <BR> Here's my example code:<BR> (defmethod register-obj :after ((dir indexing-director) (mo managed-object))<BR>   (pub-and-proc (list "indexdocument" dir (k (mid mo))))<BR>   )<BR> <BR> (defmethod delete-obj :before ((dir indexing-director) (id key))<BR>   (pub-and-proc (list "removedocument" dir (k id)))<BR>   )<BR> "register-obj" and "delete-obj" are defined in DCM.<BR> <BR> <BR> On Fri, 2006-08-11 at 17:17 -0400, Daniel Salama wrote: <BLOCKQUOTE type="CITE"> <PRE><FONT color="#000000">Hi,</FONT>

<FONT color="#000000">This may be more of a suggestion since I think I already know the  </FONT>
<FONT color="#000000">answer.</FONT>

<FONT color="#000000">I come from the Ruby On Rails world and, as some of you may know,  </FONT>
<FONT color="#000000">their Active Record module provides hooks that allow the automatic  </FONT>
<FONT color="#000000">and customized evaluation of validation rules at different stages of  </FONT>
<FONT color="#000000">the committing process.</FONT>

<FONT color="#000000">At first, I was going to as how can I hook validation rules into the  </FONT>
<FONT color="#000000">persistent machinery. I guess I could (should) always wrap my commits  </FONT>
<FONT color="#000000">in transactions and then I could perform the validation process  </FONT>
<FONT color="#000000">within the transaction and, therefore, I could commit or abort  </FONT>
<FONT color="#000000">depending on the validation results.</FONT>

<FONT color="#000000">However, as my Lisp knowledge is still limited, I'd like to suggest  </FONT>
<FONT color="#000000">for some future version of Elephant, the inclusion of some type of  </FONT>
<FONT color="#000000">macro that works somehow like a with-transaction type operation. This  </FONT>
<FONT color="#000000">macro could support generic methods that could be "customized" per  </FONT>
<FONT color="#000000">class just like CLOS generic methods to support model validation.  </FONT>
<FONT color="#000000">Just for reference, Rails validation hooks support, among others:</FONT>

<FONT color="#000000">- before validation</FONT>
<FONT color="#000000">- after validation</FONT>
<FONT color="#000000">- before create</FONT>
<FONT color="#000000">- after create</FONT>
<FONT color="#000000">- before save</FONT>
<FONT color="#000000">- after save</FONT>
<FONT color="#000000">- before destroy</FONT>
<FONT color="#000000">- after destroy</FONT>

<FONT color="#000000">Maybe some of this functionality could be implemented in the near  </FONT>
<FONT color="#000000">future. Maybe it's not that big of a deal, but, since my Lisp  </FONT>
<FONT color="#000000">knowledge is limited, I am just throwing this suggestion.</FONT>

<FONT color="#000000">Then again, maybe there is a better way to do it and I just have too  </FONT>
<FONT color="#000000">much of a Rails mentality for the time being :)</FONT>

<FONT color="#000000">Thanks,</FONT>
<FONT color="#000000">Daniel</FONT>
<FONT color="#000000">_______________________________________________</FONT>
<FONT color="#000000">elephant-devel site list</FONT>
<FONT color="#000000"><A href="mailto:elephant-devel@common-lisp.net">elephant-devel@common-lisp.net</A></FONT>
<FONT color="#000000"><A href="http://common-lisp.net/mailman/listinfo/elephant-devel">http://common-lisp.net/mailman/listinfo/elephant-devel</A></FONT>
</PRE></BLOCKQUOTE><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">_______________________________________________</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">elephant-devel site list</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="mailto:elephant-devel@common-lisp.net">elephant-devel@common-lisp.net</A></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="http://common-lisp.net/mailman/listinfo/elephant-devel">http://common-lisp.net/mailman/listinfo/elephant-devel</A></DIV> </BLOCKQUOTE></DIV><BR></DIV></BODY></HTML>