@with_db_cursor<EOL>def bake(binder, recipe_id, publisher, message, cursor):
recipe = _get_recipe(recipe_id, cursor)<EOL>includes = _formatter_callback_factory()<EOL>binder = collate_models(binder, ruleset=recipe, includes=includes)<EOL>def flatten_filter(model):<EOL><INDENT>return (isinstance(model, cnxepub.CompositeDocument) or<EOL>(isinstance(model, cnxepub.Binder) and<EOL>model.metadata.get('<STR_LIT:type>') == '<STR_LIT>'))<EOL><DEDENT>def only_documents_filter(model):<EOL><INDENT>return isinstance(model, cnxepub.Document)and not isinstance(model, cnxepub.CompositeDocument)<EOL><DEDENT>for doc in cnxepub.flatten_to(binder, flatten_filter):<EOL><INDENT>publish_composite_model(cursor, doc, binder, publisher, message)<EOL><DEDENT>for doc in cnxepub.flatten_to(binder, only_documents_filter):<EOL><INDENT>publish_collated_document(cursor, doc, binder)<EOL><DEDENT>tree = cnxepub.model_to_tree(binder)<EOL>publish_collated_tree(cursor, tree)<EOL>return []<EOL>
Given a `Binder` as `binder`, bake the contents and
    persist those changes alongside the published content.