from pylons.templating import render
from pylons import c
from formbuild import *
# from formbuild.builder.field import basic
# from formbuild.builder.field import compound
from formbuild import Form

# class MainLayout(LayoutHelpers):
# 
#     type = 'authk.model.forms.MainLayout'
# 
#     def field_start(self, **p):
#         return render(c.template_dir+'field_layout.mak', 
#             fragment=True, **p)
# 
#     def field_end(self, **p):
#         return ''

class AuthKitForm(Form):


    # Monkeypatched to reflect changes in the source.
    def get_error(self, name, default='', format=None):
        #raise Exception(self.errors)
        e = None
        for k, v in self.errors.iteritems():
            if k == name:
                e = v
                break
        if e == None:
            e = default
        if format != None and e:
            e = format%e
        return e

