<s> from cornice import Service <EOL> from colander import required , drop <EOL> from daybed . schemas import registry <EOL> fields = Service ( name = '<STR_LIT>' , <EOL> path = '<STR_LIT>' , <EOL> description = '<STR_LIT>' ) <EOL> @ fields . get ( ) <EOL> def list_fields ( request ) : <EOL> common_params = [ '<STR_LIT:name>' , '<STR_LIT:type>' , '<STR_LIT:label>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> fields = [ ] <EOL> for name in registry . names : <EOL> typefield = registry . type ( name ) <EOL> field = dict ( name = name , default_hint = typefield . hint ) <EOL> for parameter in registry . definition ( name ) . children : <EOL> if parameter . name not in common_params : <EOL> fieldtype = parameter . typ . __class__ . __name__ . lower ( ) <EOL> extras = dict ( name = parameter . name , <EOL> label = parameter . title , <EOL> type = fieldtype ) <EOL> if fieldtype == '<STR_LIT>' : <EOL> node = parameter . children [ <NUM_LIT:0> ] . typ <EOL> itemtype = node . __class__ . __name__ . lower ( ) <EOL> extras [ '<STR_LIT:type>' ] = '<STR_LIT>' <EOL> extras [ '<STR_LIT>' ] = dict ( type = itemtype ) <EOL> if parameter . missing not in ( required , drop ) : <EOL> extras [ '<STR_LIT:default>' ] = parameter . missing <EOL> field . setdefault ( '<STR_LIT>' , [ ] ) . append ( extras ) <EOL> fields . append ( field ) <EOL> return fields </s>
