Roundup Tracker - Issues

Issue 2551051

classification
Title: Transitive filters don't work in rest interface
Type: behavior Severity: normal
Components: Versions: devel
process
Status: new Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: rouilj, schlatterbeck
Priority: Keywords: rest

Created on 2019-07-11 02:38 by rouilj, last changed 2019-07-22 14:55 by schlatterbeck.

Messages
msg6574 Author: [hidden] (rouilj) Date: 2019-07-11 02:38
Search filters in roundup can be transitive.  From hyperdb.py:

  ... e.g. you can search
  for all issues where a message was added by a certain user in
  the last week with a filterspec of
  {'messages.author' : '42', 'messages.creation' : '.-1w;'}

so in theory I should be able to submit a rest call as:

  issue?messages.author=42&messages.creation=.-1w

however the current code balks at that. Stating "messages.author"
isn't a valid property of issue. I wonder if we should rework the code
in rest.py that does:

  try: 
    prop = class_obj.getprops()[key]
  except KeyError:
    raise UsageError("Field %s is not valid for %s class."%(
          key, class_name))

to something like:

  try:
    prop = class_obj.getprops()[key.split('.')[0]]
  except: ...

This should result in:

   obj_list = class_obj.filter(None, filter_props)

getting filter_props like:

  {'messages.author', [1]}

which I think is properly handled.

Two questions:

  1) Does this seem the right thing to do? Should we support
     transitive searching in the rest interface? I don't see any
     reason it's not restful. It certainly beats searching
     messages?author=42&creation=.-1w then searching
     issues?messages=123,345,678 etc. (speaking of which
      curl 'https://....net/demo/rest/data/issue/?messages=1,2'
      returns all messages for some reason, so we may have
      another bug.)

  2) Does this seem to be the right way to implement it? Given a
     filter of link.link.link.property, should we check the whole link
     chain and validate the property, or do we just rely on filter
     raising an error if the filter is nonsense?
msg6582 Author: [hidden] (schlatterbeck) Date: 2019-07-22 14:55
On Thu, Jul 11, 2019 at 02:38:23AM +0000, John Rouillard wrote:
> 
> Search filters in roundup can be transitive.  From hyperdb.py:
> 
>   ... e.g. you can search
>   for all issues where a message was added by a certain user in
>   the last week with a filterspec of
>   {'messages.author' : '42', 'messages.creation' : '.-1w;'}
> 
> so in theory I should be able to submit a rest call as:
> 
>   issue?messages.author=42&messages.creation=.-1w
> 
> however the current code balks at that. Stating "messages.author"
> isn't a valid property of issue. I wonder if we should rework the code
> in rest.py that does:
> 
>   try: 
>     prop = class_obj.getprops()[key]
>   except KeyError:
>     raise UsageError("Field %s is not valid for %s class."%(
>           key, class_name))
> 
> to something like:
> 
>   try:
>     prop = class_obj.getprops()[key.split('.')[0]]
>   except: ...

Yes!
I think there is even something like get_transitive_prop that does the
right thing.

> Two questions:
> 
>   1) Does this seem the right thing to do? Should we support
>      transitive searching in the rest interface? I don't see any
>      reason it's not restful. It certainly beats searching
>      messages?author=42&creation=.-1w then searching
>      issues?messages=123,345,678 etc. (speaking of which
>       curl 'https://....net/demo/rest/data/issue/?messages=1,2'
>       returns all messages for some reason, so we may have
>       another bug.)

Yes!

>   2) Does this seem to be the right way to implement it? Given a
>      filter of link.link.link.property, should we check the whole link
>      chain and validate the property, or do we just rely on filter
>      raising an error if the filter is nonsense?
See above, I think there is already some method to check for a correct
transitive property. If it should be implemented (tm) :-)
Note that I implemented transitive properties a very long time ago :-)

Ralf
-- 
Dr. Ralf Schlatterbeck                  Tel:   +43/2243/26465-16
Open Source Consulting                  www:   http://www.runtux.com
Reichergasse 131, A-3411 Weidling       email: office@runtux.com
History
Date User Action Args
2019-07-22 14:55:12schlatterbecksetnosy: + schlatterbeck
messages: + msg6582
2019-07-11 02:39:16rouiljsettype: behavior
versions: + devel
2019-07-11 02:38:23rouiljcreate