from gabriele renzi
August 12th, 2006
Tags:
So, even this is done, and seem to work fine.
Now, I'd like to provide the user the chance to save it, and I'm using an old patch wich gives me @Configuration.to_yaml@ and @Configuration.save@, except that it does not work :(.
It seem that the tests were not complete, and even if they pass, the dumping phase fails due to some anonymous classes in the real configuration, which is not available in the restricted world of testcases.
As for the UI: I settled on a new page (should it be a new controller?) wich shows a table with the settings and a text field near it, with a submit button. The user can then enter `contents`true" or "false" or a numeric or a string, and everything will work fine. This leaves the door open for other types, i.e. hashes, or arrays, but with the limitation of using only base types in them.
The only other chance would be using @eval@ but.. well.. it is *so* evil..
So, for now I'm just showing numerical, strings and boolean values to the user, because those are easy to type/modify, and are those that make the most sense to change from the interface.
But how to read back the values? This is a complex problem for me. Python has a great advantage over ruby here, because almost all the base types have a string constructor, so you can just do @someclass(somestring)@ and it will use the builtin parser behind the scenes.
But ruby lacks this (and sadly, lacks a @BoolClass@), so for now I'm just adding this kind of constructor to the existing classes. Suggestions on better handling of this are really really welcome.
Another thing: it would be nice if @Settings@ where @Comparable@ so I could sort them (and possibly make @Configuration.settings@ return the ordered list). Trans, if you ever read this please tell me what you think :)
Leave a Reply (use Markdown Syntax)