common: add a real __repr__ method to Form

This commit is contained in:
Benjamin Dauvergne 2016-06-16 09:56:09 +02:00
parent f0a4bdddcd
commit b0e66de926
1 changed files with 9 additions and 0 deletions

View File

@ -124,6 +124,15 @@ class Form(object):
self.submit_value = submit_value
def __repr__(self):
s = '%s(' % self.__class__.__name__
kwargs = []
for k in ('url', 'method', 'fields', 'encoding', 'submit_name', 'submit_value'):
kwargs.append('%s=%r' % (k, getattr(self, k)))
s += ', '.join(kwargs)
s += ')'
return s
def __str__(self):
s = '<form method="%s" action="%s">' % (self.method, self.url)
for field in self.fields:
s += '\n <input type="%s" name="%s" value="%s"/>' % (