def delete(template): t0 = FileInfo.delete().where( FileInfo.template_mapping << template.mappings) t0.execute() t1 = TemplateMapping.delete().where( TemplateMapping.id << template.mappings) t1.execute() t2 = Template.delete().where(Template.id == template.id) t2.execute()
def theme_apply_to_blog(theme, blog): ''' Applies a given theme to a given blog. Removes and regenerates fileinfos for the pages on the blog. ''' from core import cms cms.purge_fileinfos(blog.fileinfos) mappings_to_remove = TemplateMapping.delete().where( TemplateMapping.template << blog.templates) mappings_to_remove.execute() theme_to_remove = Template.delete().where(Template.blog == blog) theme_to_remove.execute() theme_install_to_blog(theme, blog)