Comment 1 for bug 101764

Revision history for this message
Eric Casteleijn (thisfred) wrote :

Hi,

thanks for the bug report! Basically this is something very unfortunate that
we've know about for some time, but have not been able to solve yet:

The parameters of a code source have to be stored as xml in silva document. When
the document is later viewed, the stored value is retrieved from the xml, but by
then of course it is a string.

When your python script expects an integer but gets a string, strange things,
including excessive recursion can happen.

The ways this can be solved are:

1. create a type system solely for storing code source parameter types in xml
and retrieving them from that xml later. This would be the best solution, but
will be a *lot* of work.

2. disallow any parameter type except those that can be stored and retrieved as
strings unambiguously. (I'll have to look into formulator to see how easy this
would be.) This has the drawback that we would lose the part of formulator that
*does* work here, i.e. the validation, so code source developers would have no
control over what authors would fill in, in any given parameter field.

3. Document much better how codesource parameter types currently (half) work,
i.e.: you can use an integer field, but in your script you'll have to cast from
string to integer before doing anything with the variable. The developer *does*
have the assurance that the string (s)he gets back can be safely cast to an
integer, since the validation ensures that.

For your specific case, 3. also suggests a short term work-around.