customizations.sort()
h = hash(tuple(customizations))
pdf_name = '%s-custom-%s' % (book.slug, h)
- pdf_file = models.get_dynamic_path(None, pdf_name, ext='pdf')
+ pdf_file = get_dynamic_path(None, pdf_name, ext='pdf')
return pdf_file
current_self = Book.objects.get(id=self.id)
current_self.pdf_file.save('%s.pdf' % self.slug, File(open(pdf_file.name)))
self.pdf_file = current_self.pdf_file
+
+ # remove cached downloadables
+ remove_zip(settings.ALL_PDF_ZIP)
+
+ for customized_pdf in get_existing_customized_pdf(self):
+ unlink(customized_pdf)
else:
- print "safing %s" % file_name
- print "to: %s" % DefaultStorage().path(file_name)
- DefaultStorage().save(file_name, File(open(pdf_file.name)))
+ print "save %s to: %s" % (file_name, DefaultStorage().path(file_name))
+
+ pdf_django_file = File(open(pdf_file.name))
+ DefaultStorage().save(file_name, pdf_django_file)
+ pdf_django_file.close()
finally:
+ pass
unlink(pdf_file.name)
- # remove cached downloadables
- remove_zip(settings.ALL_PDF_ZIP)
- for customized_pdf in get_existing_customized_pdf(self):
- unlink(customized_pdf)
-
def build_mobi(self):
""" (Re)builds the MOBI file.