+ def save(self, **kwargs):
+ try:
+ from bin import book2html
+ from django.conf import settings
+ from os.path import splitext, basename
+ from tempfile import NamedTemporaryFile
+
+ html_file = NamedTemporaryFile()
+ book2html.transform(self.xml_file.path, html_file)
+
+ html_filename = '%s.html' % splitext(basename(self.xml_file.path))[0]
+ self.html_file.save(html_filename, File(html_file), save=False)
+ except ValueError:
+ pass
+
+ book = super(Book, self).save(**kwargs)
+