Loading application variables
Pupeno
pupeno@REDACTED
Sun Jun 11 16:42:55 CEST 2006
On Sun, 2006-06-11 at 16:25 +0200, Ulf Wiger wrote:
> Den 2006-06-11 14:42:43 skrev Pupeno <pupeno@REDACTED>:
>
> > I understand it can be written, but since nobody has written it yet I
> > suppose people work in other ways, if so, I want to learn that instead
> > of writing a function (that doesn't belong to my project anyway, but to
> > Erlang itself).
>
> What I normally do is (possibly) use environment variables to store
> defaults, and then providing an API for setting the desired values
> at runtime.
>
> Mnesia, for example, relies on environment variables for various settings,
> but you can also call mnesia:start(Options), and set the same values that
> way. What mnesia does at startup is to read the options - either passed as
> arguments to the start function, or given as environment variables - and
> then storing them as temporary objects in the schema.
>
> The module proplists is a convenient way to handle {Key, Value} options.
> You can, for example, do:
>
> start(StartOpts) ->
> Options = StartOpts ++ application:get_all_env(?APP_NAME),
> Port = proplists:get_value(port, Options),
> ...
>
>
> The proplists module will fetch the first instance of a given key, so all
> you need to do to override the defaults is to prepend the new values to
> the list.
Does this mean that I would not be using the standard way of application
to load configuration files ?
--
Pupeno <pupeno@REDACTED> http://pupeno.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 191 bytes
Desc: This is a digitally signed message part
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20060611/c5d50602/attachment.bin>
More information about the erlang-questions
mailing list