def compoundChecker(theAnswer=CompoundChecker( [formless.Integer(label="six"), formless.Integer(label="nine")], label="The Answer", description="What is the meaning of life, the universe, and everything?" )): """The Answer Please type the integer six in the first box, and nine in the second. """ return formless.Object(label="The Answer", interface=formless.Integer)
def testInteger(self): i = formless.Integer(required=True) self.assertEqual(process(i, "0"), 0) self.assertEqual(process(i, "3409823098"), 3409823098) self.assertRaises(formless.InputError, process, i, "") self.assertRaises(formless.InputError, process, i, "a string") self.assertRaises(formless.InputError, process, i, "1.5") i = formless.Integer(required=False) self.assertEqual(process(i, "1234567"), 1234567) self.assertEqual(process(i, ""), None)
class Inner(formless.TypedInterface): one = formless.Integer() two = formless.Integer() def buckleMyShoe(): pass buckleMyShoe = formless.autocallable(buckleMyShoe) def buriedAlive(): pass buriedAlive = formless.autocallable(buriedAlive)
class ISimpleTypedInterface(formless.TypedInterface): anInt = formless.Integer() def aMethod(aString=formless.String()): return None aMethod = formless.autocallable(aMethod)
def someMethod(one=formless.Object(interface=IBar), two=formless.Integer(description="an integer please")): """Some Method. This method takes an IBar instance. """ return None
def compoundTest(aCompound=formless.Compound([ formless.String(label="firstname"), formless.String(label="lastname") ], label="Full Name"), anInt=formless.Integer()): """Compound Test A test of a widget/controller which renders multiple fields, triggers multiple validators, but gathers the result into one method argument. There can be an additional validation step which validates that the compound data as a whole is valid. """ return str
def test_1_renderWithDefaultValues(self): binding = formless.MethodBinding('haveFun', formless.Method( returnValue=None, arguments=[formless.Argument('funValue', formless.Integer(label="Fun Value", default=0))] )) def setupCtx(ctx): ctx.locate(iformless.IFormDefaults).setDefault('funValue', 15) return ctx renderer = iformless.IBindingRenderer(binding) def later(val): self.failIfSubstring('0', val) self.assertSubstring('15', val) return self.render(tags.invisible(data=binding, render=renderer), setupContext=setupCtx).addCallback( later)
class IThing(formless.TypedInterface): foo = formless.Integer()
class IAProperty(formless.TypedInterface): prop = formless.Integer()
def password(pword=formless.Password(), integer=formless.Integer()): pass
class IDefaultProperty(formless.TypedInterface): default = formless.Integer(default=2)
class IFrob(formless.TypedInterface): integer = formless.Integer()
class Inner(formless.TypedInterface): """Docstring This is a docstring. """ anInnerProperty = formless.Integer()
def bar(barbaz=formless.Integer(label="The Baz")): ## this has no docstring, make sure it doesn't fail return formless.String()
class Test(formless.TypedInterface): foo = formless.String() bar = formless.Text() baz = formless.Integer() quux = formless.Object(interface=_indirectOther())