Roundup Tracker - Issues

Issue 2551159

classification
cl.filter fails if filterspec is None
Type: crash Severity: normal
Components: Versions:
process
Status: new
:
: : rouilj, schlatterbeck
Priority: :

Created on 2021-09-01 02:26 by rouilj, last changed 2021-09-01 15:48 by rouilj.

Messages
msg7337 Author: [hidden] (rouilj) Date: 2021-09-01 02:26
I am implementing basic charting for my tracker. It uses the results of
an index page and plots a pie graph by the first group parameter.
The description is at: https://wiki.roundup-tracker.org/QueryResultPieCharts

At one point I call:

   issues = cl.filter(matches, filterspec, sort = [('+', 'id')],
                      group = group)

If my index is displaying all items in the tracker, the filterspec is
None.  I then get the following traceback:

 roundup/hyperdb.py in _proptree(self=<hyperdb.Class "issue">,
        filterspec=None, exact_match_spec={}, sortattr=[('+',
        'priority'), ('+', 'id')], retr=0)

 1573         proptree = Proptree(self.db, self, '', self.getprops(), retr=retr)
 1574         for exact, spec in enumerate((filterspec, exact_match_spec)):
 1575             for key, v in spec.items():
      key = undefined, v = undefined, spec = None, global items = undefined
 1576                 keys = key.split('.')
 1577                 p = proptree

my claim is that a None filter should create a non-filtering proptree
that will return all issues when evaluated. But I am not sure if that
is valid later in the code.

Also I am using the sqlite backend.

I can work around this by setting the filterspec passed to cl.filter
to something that will evaluate to true for every issue. But I don't
know if there is such a filter.

The other alternative is to evaulate filterspec and if None call
something other than cl.filter, maybe cl.getnodeids() but that seems
to be a bandaid over the underlying problem.

Ralf you know this code better than I do, any thoughts on how to fix
this?
msg7338 Author: [hidden] (schlatterbeck) Date: 2021-09-01 07:44
On Wed, Sep 01, 2021 at 02:26:09AM +0000, John Rouillard wrote:

> If my index is displaying all items in the tracker, the filterspec is
> None.  I then get the following traceback:
[...]

How about setting the filterspec to {}
That's what I usually use in such a case.

> my claim is that a None filter should create a non-filtering proptree
> that will return all issues when evaluated. But I am not sure if that
> is valid later in the code.

See above, an empty dictionary should do the trick.

> I can work around this by setting the filterspec passed to cl.filter
> to something that will evaluate to true for every issue. But I don't
> know if there is such a filter.
{}

Ralf
-- 
Dr. Ralf Schlatterbeck                  Tel:   +43/2243/26465-16
Open Source Consulting                  www:   www.runtux.com
Reichergasse 131, A-3411 Weidling       email: office@runtux.com
msg7339 Author: [hidden] (rouilj) Date: 2021-09-01 15:48
In message <20210901074400.2utnfvkykg2te7qw@runtux.com>,
Ralf Schlatterbeck writes:
>On Wed, Sep 01, 2021 at 02:26:09AM +0000, John Rouillard wrote:
>> If my index is displaying all items in the tracker, the filterspec is
>> None.  I then get the following traceback:
>[...]
>
>How about setting the filterspec to {}
>That's what I usually use in such a case.

Ah nice. Should we change

  def  filter(...,filterspec=None,....):

to add:

      if filterspec == None:
         filterspec = {}

at the beginning of the function?

(For those reading, filter(...,filterspec={},,,,) is not a good idea
because the {} object is persistent. So any change the method does to
filterspec will be used on the next call to filter(). Same with [].

https://pythonconquerstheuniverse.wordpress.com/2012/02/15/mutable-default-arguments/)
History
Date User Action Args
2021-09-01 15:48:37rouiljsetmessages: + msg7339
2021-09-01 07:44:07schlatterbecksetmessages: + msg7338
2021-09-01 02:26:08rouiljcreate