Roundup Tracker - Issues

Issue 2550505

classification
Simplify 'search_matches' argument to filter()
Type: rfe Severity: normal
Components: Versions: devel
process
Status: closed fixed
:
: stefan : loewis, richard, stefan, tonimueller
Priority: : patch

Created on 2009-02-16 22:27 by stefan, last changed 2009-03-21 19:33 by stefan.

Files
File name Uploaded Description Edit Remove
search_matches.patch stefan, 2009-02-16 22:27
Messages
msg3550 Author: [hidden] (stefan) Date: 2009-02-16 22:27
The roundup "filter" method (see hyperdb.py) has a "search_matches"
parameter that can be used to constrain the search.  In particular,
only elements which otherwise match the search *and* are in
search_matches will be considered.

Conceptually, 'search_matches' is a set. However, as some backend code
calls 'has_key()' on it, it needs to be a dictionary.

The attached patch simplifies this, so any sequence type may be used.

OK to check in ?
msg3551 Author: [hidden] (richard) Date: 2009-02-16 22:38
Absolutely go for it.

     Richard

Sent from my expensive toy

On 17/02/2009, at 9:27 AM, Stefan Seefeld <issues@roundup-tracker.org>  
wrote:

>
> New submission from Stefan Seefeld <stefan@codesourcery.com>:
>
> The roundup "filter" method (see hyperdb.py) has a "search_matches"
> parameter that can be used to constrain the search.  In particular,
> only elements which otherwise match the search *and* are in
> search_matches will be considered.
>
> Conceptually, 'search_matches' is a set. However, as some backend code
> calls 'has_key()' on it, it needs to be a dictionary.
>
> The attached patch simplifies this, so any sequence type may be used.
>
> OK to check in ?
>
> ----------
> assignee: stefan
> files: search_matches.patch
> keywords: patch
> messages: 3550
> nosy: richard, stefan
> severity: normal
> status: new
> title: Simplify 'search_matches' argument to filter()
> type: rfe
> versions: devel
>
> ________________________________________________
> Roundup tracker <issues@roundup-tracker.org>
> <http://issues.roundup-tracker.org/issue2550505>
> ________________________________________________
msg3552 Author: [hidden] (stefan) Date: 2009-02-16 22:43
Fixed with rev:4136
msg3649 Author: [hidden] (loewis) Date: 2009-03-16 01:52
The patch is incorrect. It leaves the line

  args = args + v

even though the variable v has no value anymore.

I fail to see where precisely search_matches is changed to be a
sequence. My testing shows it remains a dict. So the correct line should be

  args = args + search_matches.keys()

However, this is actually what it was before, so I'm puzzled...
msg3652 Author: [hidden] (stefan) Date: 2009-03-17 06:34
Martin v. Löwis @psf.upfronthosting.co.za wrote:

> The patch is incorrect. It leaves the line
> 
>   args = args + v
> 
> even though the variable v has no value anymore.

I'd propose this fix:

-            args = args + v
+            args = args + [x for x in search_matches]

as the intention of the original patch was to use 'in' so any container 
type would be possible. Richard, how does this look ?

Thanks,
		Stefan
msg3654 Author: [hidden] (stefan) Date: 2009-03-17 07:32
Martin v. Löwis @psf.upfronthosting.co.za wrote:

> The patch is incorrect. It leaves the line
> 
>   args = args + v

Where ?

> 
> even though the variable v has no value anymore.
> 
> I fail to see where precisely search_matches is changed to be a
> sequence. My testing shows it remains a dict.

The 'search_matches' object comes from (tracker instance) template code. 
All I meant to change is its handling, so it didn't have to be a dict, 
but could be any container type. (Using 'in' instead of 'has_key', to be 
more polymorphic.)

Thanks,
		Stefan
msg3655 Author: [hidden] (loewis) Date: 2009-03-17 07:41
> I'd propose this fix:
> > 
> > -            args = args + v
> > +            args = args + [x for x in search_matches]
> > 
> > as the intention of the original patch was to use 'in' so any container 
> > type would be possible. Richard, how does this look ?

If it is ok, I think there are a few less complicated spellings, such
as

   args = args + list(search_matches)
   args.extend(search_matches)
msg3656 Author: [hidden] (stefan) Date: 2009-03-17 10:52
Martin v. Löwis @psf.upfronthosting.co.za wrote:

>> I'd propose this fix:
>>> -            args = args + v
>>> +            args = args + [x for x in search_matches]

I'v checked in the above yesterday, while the tracker machine was down.

>>> as the intention of the original patch was to use 'in' so any container 
>>> type would be possible. Richard, how does this look ?
> 
> If it is ok, I think there are a few less complicated spellings, such
> as
> 
>    args = args + list(search_matches)
>    args.extend(search_matches)

Ah, I didn't know the above were valid ways to get the same effect. In 
any case, I believe it's fixed in trunk now. Please confirm, so we can 
close this issue.

Thanks,
		Stefan
msg3668 Author: [hidden] (tonimueller) Date: 2009-03-21 17:21
Hi Stefan, you wrote that you checked this patch in, esp. with this piece:

>> I'd propose this fix:
>>> -            args = args + v
>>> +            args = args + [x for x in search_matches]

I can't find this anywhere on trunk, so where did you check this in, please?

(Running 'svn up' gives me r4209 and a message that I'm up to date.)
msg3669 Author: [hidden] (tonimueller) Date: 2009-03-21 17:25
sorry... please disregard my last message
msg3670 Author: [hidden] (stefan) Date: 2009-03-21 19:33
Toni Mueller wrote:
> Toni Mueller <dev@tonimueller.org> added the comment:
> 
> Hi Stefan, you wrote that you checked this patch in, esp. with this piece:
> 
>>> I'd propose this fix:
>>>> -            args = args + v
>>>> +            args = args + [x for x in search_matches]
> 
> I can't find this anywhere on trunk, so where did you check this in, please?

On trunk (rev:4205)

http://svn.roundup-tracker.org/viewvc/roundup/roundup/trunk/roundup/backends/rdbms_common.py?r1=4187&r2=4205&pathrev=4205
History
Date User Action Args
2009-03-21 19:33:21stefansetmessages: + msg3670
2009-03-21 17:25:40tonimuellersetmessages: + msg3669
2009-03-21 17:21:33tonimuellersetnosy: + tonimueller
messages: + msg3668
2009-03-17 10:52:18stefansetmessages: + msg3656
2009-03-17 07:41:56loewissetmessages: + msg3655
2009-03-17 07:32:09stefansetmessages: + msg3654
2009-03-17 06:34:44stefansetmessages: + msg3652
2009-03-16 01:52:12loewissetnosy: + loewis
messages: + msg3649
2009-02-16 22:43:44stefansetstatus: new -> closed
resolution: fixed
messages: + msg3552
2009-02-16 22:38:06richardsetmessages: + msg3551
2009-02-16 22:27:22stefancreate