John Mettraux wrote:
> On Tue, May 25, 2010 at 04:38:18PM +0200, Torsten Schönebaum wrote:
> >
> > I'm about to update the workitems resource in RuoteKit so that items may
> > not only be filtered by participants but also by field values.
> >
> > I've done some changes
> > (http://github.com/tosch/ruote-kit/commit/8af0193b6db939cda181bf697f4c814381d90a21),
> > but one spec still fails: As the HTTP params will always be parsed as
> > strings, Ruote::StorageParticipant#query fails on non-string values like
> > numbers.
> >
> > I know that's not a bug, but it makes it much more complicated to use
> > Ruote::StorageParticipant#query together with params from http requests:
> > I'll have to convert the search string into the proper type before
> > feeding it to the query method. So there's need of another param
> > indicating the right type like that
> > GET /_ruote/workitems?wands[value]=101&wands[type]=Integer
> > That's blowing up the queries and parsing is a pain, too.
> >
> > Another solution would be a new query method in the storage participant:
> > Let it compare values after casting them to strings.
> >
> > That has a few drawbacks, too: What about field values which can't be
> > converted to strings? Converting to strings will have a performance
> > price, too, I suppose.
> >
> > You see, I'm unsure about the best way to go. What do you think?
>
> Hello Torsten,
>
> (I think this conversation should be on the mailing list)
OK, wasn't sure about that, too. This reply goes over the list.
> Why not doing it the CouchDB style :
>
> GET /_ruote/workitems?wands={"value":101,"type":"Integer"}
That's a great idea. Using JSON's native types, we can even drop the
"type" key.
> ~~>
>
> GET
> /_ruote/workitems?wands=%7B%22value%22%3A101%2C%22type%22%3A%22Integer%22%7D
>
> require 'cgi'
> CGI.escape('{"value":101,"type":"Integer"}')
>
> Granted, the simplest cases now become
>
> GET /_ruote/workitems?customer=%22Torsten%22
>
> but we could perhaps also accept the plain
>
> GET /_ruote/workitems?customer=Torsten
>
> without too much worries (if the first char of the value is a % then we
> know we have to deal with something escaped, else let's assume it's a
> String).
Sinatra does the url decoding and some parsing on the params so that we
always get an hash of strings (or even sub-hashes). We could have a look
at the raw data but I suppose it's easier to check if there are curly
brackets at the beginning and the end of the filter value and let
JSON.parse do its work in those cases.
My first try on that is in
http://github.com/tosch/ruote-kit/commit/a9dc84e7ccd71e0e78d4262ed8be31ea29497620
Thanks,
Torsten
--
you received this message because you are subscribed to the "ruote users" group.
to post : send email to [email protected]
to unsubscribe : send email to [email protected]
more options : http://groups.google.com/group/openwferu-users?hl=en