Re: Adding new file dependencies to runStaticRenderer?

Nick Moffitt <[email protected]>
Newsgroups gmane.comp.web.pyblosxom.devel
Message-ID <[email protected]>
Nick Moffitt:
> Now, I could write a hackish patch to runStaticRenderer that would
> check comment_dir along the file path and see if the comment directory
> is older than the existing .html file.  I suspect it would be a
> relative minimum of code, and could apply cleanly even after an
> upgrade to the next version.

It turned out to be as simple as I suspected.  I've attached the patch
for anyone interested in using incremental generation with comments, and
I may go on to do further hideous things with trackback if I get bored
again.

I didn't clean this patch up particularly because I don't expect that it
is much of a candidate for inclusion.  I'm pretty sure I botched the
proper meaning of comment_dir anyway, and CBA to fix it.  If anyone is
interested, I'd be happy to work on this little hack further.

-- 
Though the great song return no more                     Nick Moffitt
There's keen delight in what we have:              [email protected]
The rattle of pebbles on the shore
Under the receding wave.  -- W. B. Yeats
comment.diff (text/plain, 1.3 KB)
--- /tmp/pyblosxom.py	2006-02-13 09:04:06.000000000 -0800
+++ pyblosxom.py	2006-03-22 15:45:03.000000000 -0800
@@ -209,6 +209,7 @@
             then we render only the ones that have changed.
         @type  incremental: boolean
         """
+        import glob
         self.initialize()
 
         config = self._request.getConfiguration()
@@ -219,6 +220,7 @@
 
         staticdir = config.get("static_dir", "")
         datadir = config["datadir"]
+        commentdir = config.get("comment_dir", os.path.join(datadir, "comments"))
 
         if not staticdir:
             raise Exception("You must set static_dir in your config file.")
@@ -257,8 +259,16 @@
             except:
                 smtime = 0
 
+            # Get a pattern for all the comment files for this entry
+            commentglob = os.path.normpath(commentdir + mem) + "-*"
+            cmtime = 0
+
+            # Get the mtime of only the most recent one
+            for cmt in glob.glob(commentglob):
+                cmtime = max(cmtime, os.stat(cmt)[8])
+
             # if the entry is more recent than the static, we want to re-render
-            if smtime < mtime or not incremental:
+            if smtime < mtime or smtime < cmtime or not incremental:
 
                 # grab the categories
                 temp = os.path.dirname(mem).split(os.sep)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.