<s> from zope . interface import implements <EOL> from nevow import loaders <EOL> from nevow import rend <EOL> from nevow import tags <EOL> from nevow import inevow <EOL> from nevow import url <EOL> from formless import annotate <EOL> from formless import webform <EOL> from twisted . internet import defer <EOL> newChoicesWay = annotate . Choice ( lambda c , d : range ( <NUM_LIT:30> ) ) <EOL> deferChoicesWay = annotate . Choice ( lambda c , d : defer . succeed ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) ) <EOL> radioChoices = annotate . Radio ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> values = { <NUM_LIT:0> : dict ( name = "<STR_LIT>" , stuff = <NUM_LIT> ) , <NUM_LIT:1> : dict ( name = "<STR_LIT>" , stuff = <NUM_LIT> ) , <NUM_LIT:2> : dict ( name = "<STR_LIT>" , stuff = <NUM_LIT> ) } <EOL> customValueToKey = annotate . Choice ( <EOL> [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> ] , <EOL> stringify = lambda x : values [ x ] [ '<STR_LIT:name>' ] , <EOL> valueToKey = str , <EOL> keyToValue = lambda x : values [ int ( x ) ] ) <EOL> class IMyForm ( annotate . TypedInterface ) : <EOL> foo = annotate . Integer ( ) <EOL> def bar ( baz = annotate . Integer ( ) , <EOL> slam = newChoicesWay , ham = deferChoicesWay , radio = radioChoices , custom = customValueToKey ) : <EOL> pass <EOL> bar = annotate . autocallable ( bar ) <EOL> class Implementation ( object ) : <EOL> implements ( IMyForm ) <EOL> foo = <NUM_LIT:5> <EOL> def bar ( self , baz , slam , ham , radio , custom ) : <EOL> return "<STR_LIT>" % ( baz , slam , ham , radio , custom ) <EOL> theChoices = [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] <EOL> class FormPage ( rend . Page ) : <EOL> addSlash = True <EOL> child_webform_css = webform . defaultCSS <EOL> def render_hand ( self , ctx , data ) : <EOL> hand = inevow . IHand ( ctx , None ) <EOL> if hand is not None : <EOL> return ctx . tag [ hand ] <EOL> return '<STR_LIT>' <EOL> docFactory = loaders . stan ( <EOL> tags . html [ <EOL> tags . head [ <EOL> tags . link ( rel = '<STR_LIT>' , type = '<STR_LIT>' , href = url . here . child ( '<STR_LIT>' ) ) , <EOL> ] , <EOL> tags . body [ <EOL> tags . h3 ( render = render_hand , style = "<STR_LIT>" ) , <EOL> "<STR_LIT>" , <EOL> webform . renderForms ( '<STR_LIT>' ) , <EOL> ] , <EOL> ] , <EOL> ) </s>
