[Nitro] Simpler configuration method?
john at oxyliquit.de
Thu Jan 25 08:58:38 EST 2007
> I am thinking about replacing the current configuration/settings
> system used in Nitro and Og with a much simpler implementation
> based on global variables. Let me demonstrate with an example:
> setting :root_dir, :default => 'public', :doc => 'The default dir'
> $server_root_dir = 'public' # The default dir
Please tell me that the first looks way better to you as well. :P
> The main drawback of the current version is that you have to
> define the classes to be configured before executing any configuration
> code and/or require the glue/configuration.rb file. This prohibits
> the reusability and flexibility of the configuration files. Moreover,
Yes, this is a slight problem.
Something like that could help:
# somewhere early
Configuration.setting :KlassToConfigure, :sym, value
# rather late
class KlassToConfigure; setting :sym, :default => ''; end
So, no class is used at the start, everything should be fine.
Doesn't look as nice, but imo still better than the global var approach.
> as the configuration system uses annotations there is a slight performance
> penalty that may be serious if a configuration variable is used
> in a tight loop.
IIRC this is wrong. Configuration (when I last looked at it) used a special
implementation, saving all configurations in the `Configuration` class.
This has the huge advantage of being able to list/change some options
at runtime. (listing global vars is.... dumb?)
The current implementation could be clarified a little perhaps, but I think
that the centrality of all configuration options is a good thing in that
It could also be enhanced by writing the `Configuration` to disk to
retain changed options.... (is Cacheable?)
> I understand that global variables are considered evil, but I think
> they are very suitable for configuration. I especially like the
> fact that global variables default to nil (==false) if they are not
> previously defined.
Yes, global vars are evil. Having 50 global variables instead of the
nice configuration options right now is not sounding good to me.
Not wanting to sound like a nay-sayer, but you seem to have put quite some
energy and thoughts into new reorganizations lately. :)
With Facets 1.8 here now, maybe the best thing would be to work on integrating
that first? How about a new Roadmap.
- Caching, people still say it doesn't work. (og session cache?)
- og_clone is reportedly broken
- something went bonkers with get/post params (partly my fault due to
unchecked patch, tc failing)
There also was an issue brought up on irc:
Nitro says it depends on the daemon gem '0.4.2' or something, Mongrel 1.x
depends on daemon 1.x. Can Nitro run with the new daemon gem?
Not as fun as working on new features I admit.... /me goes pooof to learn
more for exams. ~_~
Feel the love
More information about the Nitro-general