def do_appdata_init(store): try: appdata = store.find(models.ApplicationData).one() if not appdata: raise Exception except Exception as xxx: appdata = models.ApplicationData() source = opportunistic_appdata_init() appdata.version = source['version'] appdata.fields = source['fields'] store.add(appdata) fo = Fields() fo.noisy = True fo.default_fields(appdata.fields) (unique_fields, localized_fields) = fo.extensive_dump() return unique_fields, localized_fields
def default_context_fields(): source = opportunistic_appdata_init() if not source.has_key('fields'): raise Exception("Invalid Application Data initialization") f = source['fields'] fo = Fields() fo.noisy = True fo.default_fields(f) default_fields_unhappy = fo.dump_fields('en') ret_fields = [] the_first_is_required = False for field in default_fields_unhappy: if not the_first_is_required: field['required'] = True the_first_is_required = True ret_fields.append(field) return ret_fields