[Modeling-users] Pythonic, and non-XML, Model description
Status: Abandoned
Brought to you by:
sbigaret
From: Mario R. <ma...@ru...> - 2003-02-24 22:57:24
|
Hello, following comments about the XML model (on and off the list) and how it can be improved or redone altogether, i started thinking about it... And (to be able to get it out of my mind and get to some other work ;-) here is a proposal for a pure python description of the model. It follows the XML closely, and in fact may always retain compatibility (at least generation of XML from the python model, which will be trivial). The behaviour in gnereal would stay the same as the XML way of doing things, namely form this model you would generate the classes and the db schemas. Some differences are choice of default values, and that key and locking attributes are defined on attributes and relations rather than entities ;) As an exercise, I have taken the sample model in the distribution: testPackages/StoreEmployees/model_StoreEmployees.xml and re-expressed it in this pythonic way. Apart from readability and losing of some verbosity, other gains are "executability" and dynamicity -- it could be very easy to modify a model at runtime, if you would ever want to do that. Also, given that a model now becomes a module in and of itself, it gains from what modules have to offer, such as self-tests. And, speed of course, as i see no reason why this model object would also not serve as the model object in memory at runtime (but that's for Sebastien to confirm) -- thus loading the model is equivalent to "from MyModel import model". Can you please take a look at the attached 2 files; PyModel.py -- defines the classes (signatures for) for, and documents the rules for, a PyModel instance sample_PyModel.py -- re-expresses the StoreEmployees model What does everyone think? mario |