This is

as days pass by, by Stuart Langridge

. Here I write about many things. In the past I wrote about other things but the past is past. I write code for people to play with, I write about my life on Twitter, and I write here.

On I wrote No more missing include files, on the subject of Uncategorized.

I had this problem where you'd visit the front page of kryogenix and all you'd see is, "Missing include file ../days/posts.html". The reason for this was that posts.html is a file created by Vellum that lists the last n posts, which is funkily cached, i.e., it doesn't exist until someone does an HTTP request for it. Now, the front page of kryogenix does an SSI include of that file, but it tries to include it as a file, not by doing a request. So, every time any entry in posts.html got "rebuilt" (i.e., deleted), the front page stopped working because the file wasn't there to include!

Oops.

So I fixed it by making the front page do an HTTP request for the file instead:

<?cas
import urllib
pfp = urllib.urlopen("http://www.kryogenix.org/days/posts.html")
response.write(pfp.read())
pfp.close()
?>

I do like Castalian.

Kamion

Why not just use #include virtual=“” with a relative URL rather than #include file=““? The former will trigger an Apache subrequest, which should call Vellum in the same way as a real HTTP request. Calling through urllib is, as the previous poster said, massively inefficient, and you seem to be losing yourself laziness points with the current solution. :-)

Kamion

Why not just use <!--#include virtual=""> with a relative URL rather than <!--#include file="">? The former will trigger an Apache subrequest, which should call Vellum in the same way as a real HTTP request. Calling through urllib is, as the previous poster said, massively inefficient, and you seem to be losing yourself laziness points with the current solution. :-)

sil

The reason is: I am lazy. :) I don't want to trigger generation by function call because that means that my front page has to invoke Vellum, and that's too tightly coupled. The real solution is to write a Vellum plugin that hooks the "entry-rebuild-post" event (which is triggered after any entry is rebuilt) and have that rebuild the posts.html page. But I'm at work and therefore don't like fiddling with it remotely, since I can't check it works on my local test copy first :)

Inefficient

Hey, rather than doing this (which, you have to admit, is an inefficient hack), why not alter Vellum to trigger generation by a function call, and not just by HTTP request?The overhead of the URLLib call, the response handling, the stream buffering, etc. is pretty bad.And you’d get looser coupling between HTTP and your CMS, too.(I admit, I’ve not looked at Vellum code, so I could be completely off.)

This website belongs to Stuart Langridge. Contact details are available. Don't eat yellow snow. Valid HTML5, at least in theory, except for the bits that aren't because I'm that futuristic that I'm ahead of the spec, oh yes. HTML5 help from Bruce Lawson, among others. Fonts from the superb FontSquirrel. End.