Ir al contenido principal

Ralsina.Me — El sitio web de Roberto Alsina

BartleBlog live!

I was think­ing: how can I im­ple­ment page pre­views in Bartle­Blog?

The ob­vi­ous way is to ren­der the page and open the lo­cal file. How­ev­er, the page may link or in­clude pieces that are not up­dat­ed yet in the stat­ic ver­sion, so that can give con­fus­ing re­sult­s.

Then it hit me... gen­er­ate the page on the fly and serve it. And do the same for ev­ery­thing else the brows­er asks for.

So, af­ter search­ing for 15 min­utes for the sim­plest python "web frame­work" that let me use the code al­ready in Bartle­blog, and de­cid­ing for Col­u­brid...

Now, this is cute: bartle­blog as a dy­nam­ic web app in 34 lines.

from colubrid import RegexApplication, HttpResponse, execute

from import Blog
import BartleBlog.backend.dbclasses as db
import os, codecs

class webBlog(Blog):
    def __init__(self):
        if not os.path.isdir(self.dest_dir):

class MyApplication(RegexApplication):
    urls = [
        (r'^(.*?)$', 'page'),
        (r'^(.*?)/(.*?)$', 'page'),
        (r'^(.*?)/(.*?)/(.*?)$', 'page'),
        (r'^(.*?)/(.*?)/(.*?)/(.*?)$', 'page')

    def page(self, *args):
        return HttpResponse(, path)).read())

app = MyApplication
app = StaticExports(app, {
    '/static': './static'

if __name__ == '__main__':

Contents © 2000-2024 Roberto Alsina