[MKDoc-dev] Handling Component Deletion

Sam Tregar sam at tregar.com
Sat Oct 23 19:27:47 BST 2004


Hello all.  I've found a bug in my time-range component but I'm not
sure how to solve it.  Here's how it works:

  1) Create a new document and add a time-range.  Save.

  2) Edit the document and remove the time-range.  Save.

After this the Document_TimeRange index table will still have the old
time-range data.  As it stands there's no code in place to delete the
index data when the component is deleted.  I've come up with two
possible solutions, but they both have problems:

  1) Create a new method in flo::Component called on_delete() which is
     called when a component is removed.  Implement on_delete in
     flo::editor::TimeRange to delete the row from
     Document_TimeRange.

     Problem: so far the only place I can find to call on_delete() is
     from flo::Editor::_initialize_delete.  This isn't good because
     that means the deletion happens when the user clicks delete, not
     save.  If they leave the editor without saving then the index
     will be incorrect.

  2) Move maintenance of the Document_TimeRange index to an external
     cron-job, like the existing indexing system.  This cron-job could
     analyze all the documents and make deletions to the index as
     needed.  

     Problem: the index will lag the Document table and may produce
     incorrect results between updates.  Also, because the indexing
     task will need to look at every document in the system it may be
     quite slow.

If possible I'd like to find a solution to the problem with #1.  It
seems cleaner to me to confine all the time-range logic in a single
module than to spread it across a module and an indexing script.  Any
suggestions?

-sam


 


More information about the MKDoc-dev mailing list