Navigation

TDI (/ʹtedɪ/[1]) is a
markup templating system written in python with (optional but
recommended) speedup code written in C.

Unlike most templating systems TDI does not invent its own language to
provide functionality [2]. Instead you simply mark the nodes you want to
manipulate within the template document. The template is parsed and the
marked nodes are presented to your python code, where they can be
modified in any way you want.

TDI is currently available for python2 versions only (starting with
python 2.7). Python 3 is not supported yet. The following
alternative implementations are supported:

The following code renders a calendar, i.e. days of a month specified by
the caller.

The code is intended to give you a good impression of how TDI looks
like and feels like. It also tries to present many of TDI‘s features
at once. When you read the documentation, feel free to pick it up and play around with it.

importdatetimeas_dtfromtdiimporthtmlas_htmlfromtdi.toolsimporthtmlas_html_toolsclassModel(object):MONTHS=u""" Januar Februar M\xe4rz April Mai Juni Juli August September Oktober November Dezember """.split()def__init__(self,year,month):self.first=start=_dt.date(year,month,1)self.end=(start+_dt.timedelta(31)).replace(day=1)self.name=self.MONTHS[month-1]self.year=yearself.start=start-_dt.timedelta(start.weekday())self.today=_dt.date.today()defrender_title(self,node):node.content=u"%s%04d"%(self.name,self.year)defrender_row(self,node):weeks,rest=divmod((self.end-self.start).days,7)weeks+=bool(rest)# repeat over each displayed week (each monday)node.repeat(None,(self.start+_dt.timedelta(week*7)forweekinxrange(weeks)))defrender_col(self,node):monday=node.ctx[1]# repeat over each weekdaynode.repeat(self.repeat_col,(monday+_dt.timedelta(day)fordayinxrange(7)))defrepeat_col(self,node,date):node.content=date.dayifdate.weekday()>=5:_html_tools.class_add(node,u'weekend')ifnot(self.first<=date<self.end):_html_tools.class_add(node,u'fill')ifdate==self.today:_html_tools.class_add(node,u'today')defseparate_col(self,node):ifnode.ctx[0]!=3:node.remove()tpl=_html.from_files(['layout.html','calendar.html'])tpl.render(Model(2014,1))

TDI has proven its performance and stability in high load production
environments, which means, it works and it’s stable. There are still
some kinks to solve and a few missing minor features to add until TDI
reaches version 1.0. So, development wise it’s effectively a beta
release right now.

There are hashes (MD5, SHA1 and SHA256) of the download packages stored
in the digests file. In order to
check the integrity of the downloaded file, use a tool like md5sum (or
sha1sum, sha256sum accordingly), e.g.:

TDI is available under the terms and conditions of the “Apache License,
Version 2.0.” You’ll find the detailed licensing terms in the root
directory of the source distribution package or online at
http://www.apache.org/licenses/LICENSE-2.0.

Various people helped developing and improving TDI itself. They are
listed in alphabetical order:

Lumes

Sebastian Dauß

Astrid ‘Kess’ Malo

Jens Michlo

Javier ‘Jay’ Rodriguez-Stegmaier

Roland Sommer

Last but not least I’d like to thank the author of HTMLTemplate. At the time I started
experimenting with document tree based template systems, HTMLTemplate
was short-listed. However, it had a different license back then, which
was unacceptable for my purposes and also missing some features, so
TDI was grown in the first place.