Viewing posts for the category Python

basic small web application with mod_wsgi and python

So i needed some quick way to verify email newsletter subscriptiosn .. (new european dataprotection laws ..)

Python Dataset Library -- CSV to SQLite ;)

Out of frustration of just needing to handle some (temporary) data properly and save it (csv and json are nice, but i wanted sqlilte in this case to query it easier) I found the dataset library.

Sending Multipart MIME Emails (html + text alternative) using python and twisted

I needed a way to send html + plain text alternative emails (based on templates ultimately) - preferrably using python. and since I always liked twisted i turned to that again.

Mezzanine with mod_wsgi in virtualenv on apache (on Gentoo)

So .. since this page/blog is running on Mezzanine I thought I'd share what I had to do to get it to work.

Nevow HTML Table rendering with xhtml template and stan

Very short example of a Page with xml template and a table which is used to render some data (with stan).
Thanks to Brend for sharing this with me (he also said that there is probably some way to do it without stan, but I quite like this as it is easy to use):

First up the python code(I'll sort out the indent issues later but for now just add the appropriate indent for python code - if you don't know what I mean you should probably read a python howto first):

from nevow import rend
from nevow import loaders
from nevow import tags as T

class SiteRoot(rend.Page):
    addSlash = True
    docFactory = loaders.xmlfile('templates/page.xml')
    def data_title(self, ctx, data):
        return u'Blechlager Verwaltung'
    def render_testTable(self, ctx, data):
        rows = [[11,12],[21,22],[31,32]]
        tags = []
        for (a, b) in rows:
            tags.append( [ [ a ], [ b ] ])
        ctx.tag = tags
        return ctx.tag