Viewing posts for the category Python
So i needed some quick way to verify email newsletter subscriptiosn .. (new european dataprotection laws ..)
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.
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.
So .. since this page/blog is running on Mezzanine I thought I'd share what I had to do to get it to work.
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
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( T.tr [ T.td [ a ], T.td [ b ] ])
ctx.tag = tags