class Scaffold(object):
def __init__(self, formclass):
self.formclass = formclass
def generate(self, row):
html = ''
fields = self.formclass.base_fields
for i in fields:
html += row % {'field': i}
return html
def as_dl(self):
return self.generate('''
{{ form.%(field)s }}
{%% if form.%(field)s.errors %%}
{%% for error in form.%(field)s.errors %%}
{{ error }}
{%% endfor %%}
{%% endif %%}
''')
def as_ul(self):
return self.generate('''
{{ form.%(field)s }}
{%% if form.%(field)s.errors %%}