On Tue, 10 Apr 2012, Samuele Kaplun wrote:
> So, considering the previous comment of Alexander, in the end, I am
> going for introducing a new variable:
> CFG_BATCHUPLOADER_WEB_ROBOT_AGENTS (with the added 'S') and with the
> regexp syntax. If some client have customized the old
> CFG_BATCHUPLOADER_WEB_ROBOT_AGENT, when inveniocfg
> --update-config-py|-- update-all is run, a WARNING will be printed on
> screen explaining the change to be performed.
1) Yes, a new variable like CFG_BATCHUPLOADER_WEB_ROBOT_AGENT_REGEXP
would be the cleanest solution. If this one was not set locally but
_AGENT was, then inveniocfg should raise a warning about _AGENT found
but it is going to be deprecated soon, but inveniocfg still recognise it
none the less and should populate new variable _AGENT_REGEXP based on
what was found in the good old _AGENT variable locally. And in a few
later Invenio releases, we can remove support for variables that were
deprecated since a long time, say two release series.
2) Another option is to check for type. IIRC we used this technique for
some variables already. Consider the old syntax was:
CFG_FOO = a,b
and the new wanted syntax is:
CFG_FOO = {'a': 100, 'b': 99}
Here, inveniocfg should try to load CFG_FOO as if it were a Python
dictionary, and if it succeeds, then all is well and good, we are in the
`new' syntax branch, and we are done. If it does not succeed, then try
to read it as if it were a comma-separated string, and if it succeed,
then all is well and good, we are in the `old' syntax branch, so we can
generate proper new CFG_FOO out of it. (Or stop and ask admin for human
resolution, if need be.) If it does not matches either new or old type,
then stop with an error.
In this case, the docstring in `invenio.conf' would mention that both
old and new syntax are supported, but that old one is going to be
deprecated sooner or later. Quite like _ROBOT vs _ROBOT_REGEXP variable
deprecation.
Best regards
--
Tibor Simko