-
Kirill Smelkov authored
Since zodbdump start (c0a6299f "zodbdump - Tool to dump content of a ZODB database (draft)") and up till now zodbdump output format was not good. For example user and description transaction properties were output without proper quoting, which in situation when there would be fancy characters in there would break the output. So start the format stabilization: - user and description are output as quoted, so now they are guaranteed to be on one line. The quoting character is always " (instead of e.g. smartly quoting either by ' or " as python does) for easier compatibility with ZODB implementations in other languages. - transaction extension is now printed as raw bytes, not as dict. The idea here is that `zodb dump` * should perform dump of raw data as stored inside ZODB so that later `zodb restore` could restore the database identically to the same state. * we should dump raw data instead of unpickled ones because generally on-disk extension's format can be any raw bytes and this information should be preserved. - transaction status is now also output as quoted to preserve line breakage on fancy status codes. - it is documented that sha1 is not the only allowed hash function that might be used. - in hashonly mode we add trailing " -" to obj string so that it is possible to distinguish outputs of `zodb dump` and `zodb dump -hashonly` without knowing a-priory the way it was produced. The reason to do so is that it would be not good to e.g. by accident feed hashonly output to (future) `zodb restore`, which, without having a way to see it should not consume object data would read following transaction information as raw object data with confusing later errors (and a small chance to restore completely different database without reporting error at all). Because ZODB iteration API gives us already unpickled extension and only that, for now to dump it as raw we get a long road to pickle it back also caring to try to pickle in stable order. Hopefully this will be only a fallback because of https://github.com/zopefoundation/ZODB/pull/183 and next zodbtools patch. ~~~~ For testing purposes (currently only quoting function unit test) py.test usage is introduced. The code is also generally polished here and there.
75c03368