Prev Next

Formless builds forms from descriptions of variables to be found to the form results.


class TaxonName(formless.Typed):
"""If we can validate the form entry as a scientific or common name,
return tsn, else raise an error."""
def coerce(self, val):
val = val.strip ()
txn = itis_if.tree.itis.findTaxonTsn (val)
if txn == None:
raise formless.InputError("'%s' not found " % val)
return txn.tsn

class ILookup(formless.TypedInterface):
def lookupName(self, name=TaxonName (
label = "Taxon name (common or scientific):")):
pass
# Note that capitalization indicates word breaks here.

lookupName = formless.autocallable(lookupName, action="Search")

class Main(rend.Page):
__implements__ = ILookup, rend.Page.__implements__
docFactory = rend.stan(
tags.html[
tags.body[
tags.h1["Enter taxon name:"],
freeform.renderForms ()]])
def lookupName (self, *args, **kw):
request = self.context.locate (inevow.IRequest)
request.setComponent (inevow.IRedirectAfterPost,
"/taxon/" + kw['name'])