Re: Doing content-based mtime determination
will guaraldi <[email protected]>
| Newsgroups | gmane.comp.web.pyblosxom.user |
|---|---|
| Message-ID | <[email protected]> |
Yeah... This is kind of a pain in the ass. cb_filestat is the callback that returns the mtime for a given file and it gets called in a bunch of places internally and in various plugins. The problem is that cb_filestat is operating on the filename and mtime (as returned by the previous cb_filestat call) of the given entry--it doesn't have the entry object. There are a couple of bad reasons for this. The first is that building an entry object is somewhat expensive because of our entry parsers and such. In the blosxom handler we do a filestat on all the filenames, then sort them, then build entry objects out of the ones we're interested in rendering. I'm not really sure if that was a great idea or not. So, to solve your specific problem, one possibility is that you could implement cb_filestat. Your function would open the file (possibly using the FileEntry stuff), force the entry to read the file in and thus grab the metadata for the file, and then parse that for the mtime. Another possibility is that you run an external process that goes through all your entries parsing out the mtimes and storing them in a centralized file with the key being the entry file name and then have your cb_filelist function pull the mtime from that. Let me know what you're thinking. We're due for a PyBlosxom 1.1 release--there are several fixes that are sitting in the CVS codebase (the specifics escape me at the moment) and maybe this is a good time to reevaluate some of the "interesting" things we did and undo/simplify/fix them. /will On Tue, 17 Aug 2004, David Ascher wrote: > > I was trying to write a plugin that basically determined the effective > mtime of an entry based on an in-entry tag like: > > TIMESTAMP::2002-04-01-00-00 > > I like this approach over the date-in-filename approach because > mucking with the filename means mucking with the URLs of permalinks. > > Unfortunately, it appears that the entry hasn't been parsed by the > time cb_filestat gets called. Is the right approach in this case to > have a cb_filelist handler? It seems it would be too late, and other > plugins which limit things based on date would have gotten it 'wrong' > by the time cb_filelist got called. > > Any advice appreciated. > > --david ------------------------------------------------------- SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285