- 03 Mar, 2015 2 commits
-
-
Kirill Smelkov authored
Current BigFile code in many places assumes .data property is either None or BTreeData instance. But as already shown in 4d8f0c33 (BigFile: Fix non-range download of just created big file) this is not true and .data can be an str. This leads to situations where code wants to act on an str, like on a BTreeData instance, e.g. def _range_request_handler(): ... if data is not None: RESPONSE.setHeader('Last-Modified', rfc1123_date(data._p_mtime)) or def _read_data(... data=None): ... if data is None: btree = BTreeData() else: btree = data ... btree.write(...) and other places, and in all those situation we'll get AttributeError (str has neither ._p_mtime nor .write) and it will crash. ~~~~ .data can be str at least because '' is the default value for `data` field in Data property sheet. From this proposition the code could be reorganised to work in "data is either BTreeData or empty (= None or '')" But we discussed with Romain and his idea is that non empty strings have to be too supported because of compatibility reasons and because of desire to support possible future automatic File-based documents migration to BigFiles. From this perspective for BigFile the invariant thus .data is either BTreeData or str (empty or not) or None. This patch goes through whole BigFile code and corrects places to either properly support str case, or None (in e.g. computing len(data) in index_html). In _read_data() if data is previously str - that means we are appending content to this file and thus it is a good idea to first convert str (empty or not) to BTreeData and then proceed with appending. Helped-by: Vincent Pelletier <vincent@nexedi.com> Reviewed-by: Romain Courteaud <romain@nexedi.com>
-
Kirill Smelkov authored
Since .data can be BTreeData or None (or as we'll see next and str), ._p_mtime() is not always defined on it and in several places current code has branches from where to get it. Move this logic out to a separate helper and the code which needs to know mtime gets streamlined. Suggested-by: Vincent Pelletier <vincent@nexedi.com>
-
- 02 Mar, 2015 1 commit
-
-
Kirill Smelkov authored
Because we next pass that btree to ._read_data() and read_data() intentionally creates empty BTreeData() when btree is initially None. Reviewed-by: Romain Courteaud <romain@nexedi.com>
-
- 23 Feb, 2015 1 commit
-
-
Kirill Smelkov authored
If in erp5 I go to big_file_module and 'Add Big File' action and then try to download just-created empty bigfile I get a crash: curl ... --data 'format=raw' http://localhost:8889/erp5/big_file_module/18 ... <h2>Site Error</h2> <p>An error was encountered while publishing this resource.</p> <p> <strong>Error Type: AttributeError </strong> <br /> <strong>Error Value: 'str' object has no attribute 'iterate' </strong> <br /> </p> with exception traceback Traceback (innermost last): Module ZPublisher.Publish, line 138, in publish request, bind=1) Module ZPublisher.mapply, line 77, in mapply if debug is not None: return debug(object,args,context) Module ZPublisher.Publish, line 48, in call_object result=apply(object,args) # Type s<cr> to step into published object. Module Products.ERP5.Document.BigFile, line 297, in index_html for chunk in data.iterate(): AttributeError: 'str' object has no attribute 'iterate' I've compared BigFile code with the sample place in File code from Zope/src/OFS (which is base class for BigFile) https://github.com/zopefoundation/Zope/blob/2.13/src/OFS/Image.py#L420 and in index_html(), if we requested the data itself, there it sees whether self.data is either 1) simply bytes (= str in python2), or 2) linked-list of Pdata and in BigFile we currently miss handling 1) case. ~~~~ BigFile, it looks, was copied-and-modified from Zope.OFS.Image.File first in 65121be7 (Support streaming big file in DMS.) Then in index_html download there was only an 'iterate over btree chunks' case. Later in dff53681 (Get modification date from btree.) a case for if data is None: return '' was added before btree iteration. Here we also restore original Zope code for returning file content if it is string instance directly, because as it is experimentally observed, that case can also happen. The patch does not add tests, because currently BigFile class does not have tests at all (at least I could not find them). Reviewed-by: Romain Courteaud <romain@nexedi.com>
-
- 21 Feb, 2015 3 commits
-
-
Kazuhiko Shiozaki authored
-
Kazuhiko Shiozaki authored
-
Kazuhiko Shiozaki authored
-
- 18 Feb, 2015 1 commit
-
-
Jérome Perrin authored
-
- 17 Feb, 2015 30 commits
-
-
Jérome Perrin authored
This reverts commit 2a061744. An outdated customization of Base_getEditorFieldPreferredTextEditor on our ERP5 introduced confusion
-
Sebastien Robin authored
-
Sebastien Robin authored
-
Sebastien Robin authored
-
Sebastien Robin authored
In testInventoryAPI we test several cases of getNextNegativeInventory. Remove this test which is long, hard to understand, and only test a case that is not really making sense (current stock with negative inventory)
-
Sebastien Robin authored
This avoid differences like 07:55:27 != 07:55:26 in tests
-
Sebastien Robin authored
-
Sebastien Robin authored
-
Sebastien Robin authored
-
Sebastien Robin authored
-
Sebastien Robin authored
-
Sebastien Robin authored
-
Sebastien Robin authored
-
Sebastien Robin authored
-
Sebastien Robin authored
the display of this form was broken
-
Sebastien Robin authored
This is needed to take into account the node when looking at the history of movements
-
Sebastien Robin authored
-
Sebastien Robin authored
-
Sebastien Robin authored
So all newSimulation expected failures are removed. Make generateMovementListForStockOptimisation looking min_flow and max_delay on supply lines. Introduce a getNextAlertInventoryDate in addition to getNextNegativeInventoryDate. This allows to know when an inventory will be below a reference quantity. This is particularly helpful to know when an inventory is below the minimal admitted stock
-
Sebastien Robin authored
So it's no longer a newSimulation expected failure. Review method generateMovementListForStockOptimisation of builders to nicely generated temporary movements depending on future negative stocks.
-
Sebastien Robin authored
Like this we stop using Resource_zGetInventory which is less and less used. Indeed, it's better to only have Resource_zGetInventoryList and sometimes returns a list of a single line.
-
Sebastien Robin authored
-
Sebastien Robin authored
-
Sebastien Robin authored
-
Sebastien Robin authored
Now production steps are defined in business process which are using trade_phase. indistrial_phase was used at the time of supply chains
-
Julien Muchembled authored
-
Julien Muchembled authored
-
Julien Muchembled authored
-
Julien Muchembled authored
MRP was broken and unused for a long time, since legacy simulation was dropped. This commits resuscitates MRP, at least: - expanding, for both operation and sourcing - building of production reports & production packing lists Business Processes replaces Supply Chains. trade_phase replaces industrial_phase industrial_phase is now used to variate partially produced resources.
-
Yusei Tahara authored
-
- 16 Feb, 2015 2 commits
-
-
Sven Franck authored
-
Sven Franck authored
-