View Single Post
Old 10-28-2015, 01:04 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,378
Karma: 27230406
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
The idea is that you always use container provided methods to do file I/O. If you want to work on a parsed representation, use container.parsed() and after you are done, use container.dirty(). If you want to work with bytes use

container.raw_data() and to write container.open(name, 'wb'). These methods automatically take care of dirtied items and the parsed cache.

Never write to filesystem files directly. As for previewing in QWebView, you need to virtualize access to the files via QNetworkManager, see how it is done in the editor in the live preview panel (preview.py)

The only thing to keep in mind is that you must never mix the two modes of working -- parsed vs. raw. Finish working in one mode, then start working in the other.
kovidgoyal is offline   Reply With Quote