[GRASS-dev] GUI modeler: trouble with loop variables according to type

Trying to build a model with a loop in which the output map of a command
is the loop variable, I came across the following issue.

The model is just one command, r.neighbors, with output=%output. The loop
is defined as 'output in range(1995,1998)'. When trying to run this model,
I get this error:

Traceback (most recent call last):
  File "/usr/lib/grass64/etc/wxpython/gmodeler/frame.py",
line 475, in OnRunModel

self.model.Run(self.goutput, self.OnDone, parent = self)
  File "/usr/lib/grass64/etc/wxpython/gmodeler/model.py",
line 620, in Run

log = log, onDone = onDone)
  File "/usr/lib/grass64/etc/wxpython/gmodeler/model.py",
line 487, in RunAction

log.RunCmd(command = item.GetLog(string = False, substitute
= params),
  File "/usr/lib/grass64/etc/wxpython/gmodeler/model.py",
line 976, in GetLog

cmd[idx] = pattern.sub(value, cmd[idx])
  File "/usr/lib/python2.6/re.py", line 273, in _subx

template = _compile_repl(template, pattern)
  File "/usr/lib/python2.6/re.py", line 258, in
_compile_repl

p = sre_parse.parse_template(repl, pattern)
  File "/usr/lib/python2.6/sre_parse.py", line 700, in
parse_template

s = Tokenizer(source)
  File "/usr/lib/python2.6/sre_parse.py", line 187, in
__init__

self.__next()
  File "/usr/lib/python2.6/sre_parse.py", line 189, in
__next

if self.index >= len(self.string):
TypeError
:
object of type 'int' has no len()

When I reformulate the loop as 'output in ['1995', '1996', '1997'] it works.

I understand that this is a variable type issue. However, when I run the
same model as a python script, both forms are accepted. Any chance the GUI
modeler could accept the range() form as well ? This makes creating loops
less typing-intensive as having to write out the numbers as strings.

I can get it to work by using 'output in map(str, range(1995,1998))', but
this requires a fairly good knowledge of Python, so if the simple range
command could work, just as it does in the Python version of the script, I
think this would be preferable as it would keep things in sync between the
two.

I've attached images of the model to make my issue clearer (obviously this
is just a test model which does nothing useful).

Moritz

(attachments)

model_loop_no_error.png
model_loop_provoking_error.png