Roundup Tracker - Issues

Issue 1049799

classification
Lost selections after raised error message
Type: Severity: normal
Components: Web interface Versions:
process
Status: closed fixed
:
: richard : marlonvdb, richard
Priority: normal :

Created on 2004-10-19 07:01 by marlonvdb, last changed 2005-02-13 23:36 by richard.

Messages
msg1496 Author: [hidden] (marlonvdb) Date: 2004-10-19 07:01
Hi all,

We have a problem with lost selections for 'Link'
properties after a failed
submit.
This is what happens:
- we select a status which requires
  a message to (handled by detector)
- we press submit
- we get the message (generated in the detector):
  'The selected status requires a comment, please enter it'
- but at this state, the status field contains the previous
  status again and not the one selected before the commit.
The result is that we have to check all the selections
again before trying
to submit again, or else a lot of issues do contain the
wrong selections.
The above is the case for all the 'Link' properties,
thus not only for the
'status' property.

Some additional info:
Server: Linux
web-server: roundup-server
web-clients: IE 4.0, 5.0, 5.5, 6.0 and Mozilla Firefox 1.0

python (on server): V2.3.3


Best regards,
Marlon
msg1497 Author: [hidden] (marlonvdb) Date: 2004-10-19 10:37
Logged In: YES 
user_id=1080231

I might have found the cause and solution for this one.

Method *__getitem__* of  class *HTMLItem*  doesn't look at
the *request/form* values. It should look at those first and
if not there, then look at the database values. Currently it
anly looks at the database values.

In cgi/templating.py line 641 (for 0.7.8) is says:
            value = self._klass.get(self._nodeid, item, None)
Replace that line with:
            form = self._client.form
            if form.has_key(item):
                if isinstance(prop, hyperdb.Multilink):
                    value = lookupIds(self._db, prop,
                        handleListCGIValue(form[item]),
fail_ok=1)
                elif isinstance(prop, hyperdb.Link):
                    value = form[item].value.strip()
                    if value:
                        value = lookupIds(self._db, prop,
[value],
                            fail_ok=1)[0]
                    else:
                        value = None
                else:
                    value = form[item].value.strip() or None
            else:
            	value = self._klass.get(self._nodeid, item, None)
It did solve the problem in our tracker.

Regards,
Marlon
msg1498 Author: [hidden] (marlonvdb) Date: 2004-10-20 09:45
Logged In: YES 
user_id=1080231

I whish I could say otherwise, but I'm afraid that my patch
gives other (more serious) problems.

When accessing a search url like:
issue?@columns=id,type,title,assignedto,status&@sort=-id&@group=product&@filter=status&@pagesize=50&@startwith=0&status=-1,1,2,3,4,7,9,10&@template=index
an templating error does occur with the message:
    exceptions.IndexError: no such status node -1,1,2,3,4,7,9,10
    1. In python expression "i.status.plain() or default"
    2. While evaluating the  expression on line 197
    3. A problem occurred in your template "issue.index.html".

The reason is, that the url contains a *status* property.
That one will be present in the self._client.form dictionary
and so the patch will use that one on the index page. The
result is the error.

I came up with a possible solution, although I'm not really
proud of it because I'm relying on the assumption that
properties in URL's are only used in combination with the
'@filter' or ':filter' definition. If others have used
properties in there URL for other home made causes, then
this patch will break there home made feature :-(

In the *origional* cgi/templating.py on line 641 (for 0.7.8)
where it says:
            value = self._klass.get(self._nodeid, item, None)
Replace that line with:
            form = self._client.form
            # check if the value comes from the form
            if form.has_key(item):
                # need to check first if it is needed for
the filter
                filter = None
                for name in [':filter', '@filter']:
                    if form.has_key(name):
                        filter = form[name].value.strip() or
None
                        if filter:
                            break
                
                # if not for filter
                if not filter or not item in filter.split(','):
                    if isinstance(prop, hyperdb.Multilink):
                        value = lookupIds(self._db, prop,
                            handleListCGIValue(form[item]),
fail_ok=1)
                    elif isinstance(prop, hyperdb.Link):
                        value = form[item].value.strip()
                        if value:
                            value = lookupIds(self._db,
prop, [value],
                                fail_ok=1)[0]
                        else:
                            value = None
                    else:
                        value = form[item].value.strip() or None
                else:
                    # form value is meant for the filter,
take value from database
                    value = self._klass.get(self._nodeid,
item, None)
            else:
                # not in form, take value from database
                value = self._klass.get(self._nodeid, item,
None)

Regards,
Marlon
msg1499 Author: [hidden] (marlonvdb) Date: 2004-10-20 09:45
Logged In: YES 
user_id=1080231

I whish I could say otherwise, but I'm afraid that my patch
gives other (more serious) problems.

When accessing a search url like:
issue?@columns=id,type,title,assignedto,status&@sort=-id&@group=product&@filter=status&@pagesize=50&@startwith=0&status=-1,1,2,3,4,7,9,10&@template=index
an templating error does occur with the message:
    exceptions.IndexError: no such status node -1,1,2,3,4,7,9,10
    1. In python expression "i.status.plain() or default"
    2. While evaluating the  expression on line 197
    3. A problem occurred in your template "issue.index.html".

The reason is, that the url contains a *status* property.
That one will be present in the self._client.form dictionary
and so the patch will use that one on the index page. The
result is the error.

I came up with a possible solution, although I'm not really
proud of it because I'm relying on the assumption that
properties in URL's are only used in combination with the
'@filter' or ':filter' definition. If others have used
properties in there URL for other home made causes, then
this patch will break there home made feature :-(

In the *origional* cgi/templating.py on line 641 (for 0.7.8)
where it says:
            value = self._klass.get(self._nodeid, item, None)
Replace that line with:
            form = self._client.form
            # check if the value comes from the form
            if form.has_key(item):
                # need to check first if it is needed for
the filter
                filter = None
                for name in [':filter', '@filter']:
                    if form.has_key(name):
                        filter = form[name].value.strip() or
None
                        if filter:
                            break
                
                # if not for filter
                if not filter or not item in filter.split(','):
                    if isinstance(prop, hyperdb.Multilink):
                        value = lookupIds(self._db, prop,
                            handleListCGIValue(form[item]),
fail_ok=1)
                    elif isinstance(prop, hyperdb.Link):
                        value = form[item].value.strip()
                        if value:
                            value = lookupIds(self._db,
prop, [value],
                                fail_ok=1)[0]
                        else:
                            value = None
                    else:
                        value = form[item].value.strip() or None
                else:
                    # form value is meant for the filter,
take value from database
                    value = self._klass.get(self._nodeid,
item, None)
            else:
                # not in form, take value from database
                value = self._klass.get(self._nodeid, item,
None)

Regards,
Marlon
msg1500 Author: [hidden] (richard) Date: 2005-02-13 23:36
Logged In: YES 
user_id=6405

 
History
Date User Action Args
2004-10-19 07:01:10marlonvdbcreate