Feature: Add support for restricted cuba key in DataContainer#293
Conversation
also restored import path for CUBA to the original (minor)
Current coverage is 96.62%@@ master #293 diff @@
==========================================
Files 49 49
Lines 3814 3814
Methods 0 0
Messages 0 0
Branches 570 566 -4
==========================================
+ Hits 3684 3685 +1
Misses 42 42
+ Partials 88 87 -1
|
|
Restricting keywords for a data container (e.g. by specifying a fixed set of supported keywords at the initialization) is something we have been discussing for a long time now and is related to several aspects of the SimPhoNy design (see at least issues #29, #216, #217, #223). I continue to favour implementing this feature. In addition, the proposed implementation with a restricted subclass of the data container and utilization of the frozenset seems elegant. |
|
It seems to me that |
|
I'm in favor of type and consistency checking in metadata classes and CUDS itself. IMO the functionality of |
Do you mean using |
|
Your latest code example is close to what I intended and looks good to me. As long as the use of the factory method is internal, it is fine. |
|
Just added an optional argument to the |
In order to replicate the keyword checking in
MaterialRelation(https://github.com/simphony/simphony-common/blob/master/simphony/cuds/material_relations/material_relation.py#L107) for all the generated classes from simphony-metadata, it would be more effective if the checking is done at theDataContainerlevel.For example:
Performance of the DataContainer is basically the same to the one we have now. Benchmark:
(Running with Ubuntu 12 on a VM with 1 core, 2.5GHz, 4GB RAM)
Please consider this as a proposal and please comment, review or propose alternatives.