Cobbler leveraged JSON for saving object representations to disk (though not for wire transport, where it used XMLRPC, but that is another story). The object representation system in 2.0, which I called “FIELDS” was used to define the members of each object was a little more heavy weight than I liked. This made it difficult to add new “nouns” into Cobbler, and made modelling system interfaces (which I didn’t want quite to be their own objects), rather hard. Why? The serialization and de-serialization to and from objects was not as recursive as it could be. We also had a top level orchestrator object called “config” that did not do much, that I always wanted to get rid of.
I have.
Here is a rough example of doing all of that more automagically.
The base class is /somewhat/ gnarly because of the automagic, but I don’t think the object classes could be any simpler. Notice the type checking that is also built in. Bonus! So you can work in JSON objects all day, but your code gets to work in /objects/, not error prone nested hashes.
Extra validation can be added by writing setter functions, which are, by default, optional .. you get free type checking without the setters.
Just couldn’t stay away could you? I knew you would be back!!
haha
LOL, yeah, a bit… I think I actually posted this to cobbler-devel but somebody may need to approve as I wasn’t subscribed yet (though I thought I was, with delivery off).
Though notice this is not quite a patch, meaning there could be some hope for such addictions
It looks pretty cool. I’ll check out that post to cobbler-devel. I like the idea of reducing the amount of code in cobbler so we have less to maintain.
As a side note, hook this library up to a couchdb instance via the a tornado front end and you have something that is pretty sweet!
I smell a 3.0 plan. Zero forwards compat, all ass kicking?
I’ve upgraded this some recently to support lists of objects as well, still auto-serialized, though it breaks the setattr/getattr stuff which helps keeps things clean. I may push an update or perhaps I’ll just post it in parallel so folks can choose.