Seaside REST optional query parameters

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Seaside REST optional query parameters

xx397
Does SeasideREST support optional query parameters so that you only have
to write the one handler?

i.e.
getFoo: bar baz: baz
<get>
<path: '/foo?bar={bar}&baz={baz}'>

and the baz variable is nil if the user just navigates to /foo?bar=1.

Currently it won't match the path handler. There is a mention on the
quick start about how some of the more complicated matching techniques
can be applied to the query arguments but I can't see how to do it. Is
it possible to use regex?

Thanks
Chris
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Seaside REST optional query parameters

Philippe Marschall
On Sun, Mar 24, 2013 at 1:08 PM, Chris <[hidden email]> wrote:

> Does SeasideREST support optional query parameters so that you only have to
> write the one handler?
>
> i.e.
> getFoo: bar baz: baz
> <get>
> <path: '/foo?bar={bar}&baz={baz}'>
>
> and the baz variable is nil if the user just navigates to /foo?bar=1.
>
> Currently it won't match the path handler. There is a mention on the quick
> start about how some of the more complicated matching techniques can be
> applied to the query arguments but I can't see how to do it. Is it possible
> to use regex?

No, there isn't right now. But you can fake it by removing the
optional arguments from the pragma and manually looking them up.

getFoo: bar baz: baz
 <get>
 <path: '/foo?bar={bar}'>
 | baz |
 baz := self requestContext request at: 'baz' ifAbsent: [ nil ]

Cheers
Philippe
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Seaside REST optional query parameters

xx397
On 24/03/2013 14:55, Philippe Marschall wrote:

> On Sun, Mar 24, 2013 at 1:08 PM, Chris <[hidden email]> wrote:
>> Does SeasideREST support optional query parameters so that you only have to
>> write the one handler?
>>
>> i.e.
>> getFoo: bar baz: baz
>> <get>
>> <path: '/foo?bar={bar}&baz={baz}'>
>>
>> and the baz variable is nil if the user just navigates to /foo?bar=1.
>>
>> Currently it won't match the path handler. There is a mention on the quick
>> start about how some of the more complicated matching techniques can be
>> applied to the query arguments but I can't see how to do it. Is it possible
>> to use regex?
> No, there isn't right now. But you can fake it by removing the
> optional arguments from the pragma and manually looking them up.
>
> getFoo: bar baz: baz
>   <get>
>   <path: '/foo?bar={bar}'>
>   | baz |
>   baz := self requestContext request at: 'baz' ifAbsent: [ nil ]
Hi Philippe

That was how I was attempting to get around it but it fails the path
match if you add baz to the url.
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Seaside REST optional query parameters

Philippe Marschall
On Sun, Mar 24, 2013 at 5:01 PM, Chris <[hidden email]> wrote:

> On 24/03/2013 14:55, Philippe Marschall wrote:
>>
>> On Sun, Mar 24, 2013 at 1:08 PM, Chris <[hidden email]> wrote:
>>>
>>> Does SeasideREST support optional query parameters so that you only have
>>> to
>>> write the one handler?
>>>
>>> i.e.
>>> getFoo: bar baz: baz
>>> <get>
>>> <path: '/foo?bar={bar}&baz={baz}'>
>>>
>>> and the baz variable is nil if the user just navigates to /foo?bar=1.
>>>
>>> Currently it won't match the path handler. There is a mention on the
>>> quick
>>> start about how some of the more complicated matching techniques can be
>>> applied to the query arguments but I can't see how to do it. Is it
>>> possible
>>> to use regex?
>>
>> No, there isn't right now. But you can fake it by removing the
>> optional arguments from the pragma and manually looking them up.
>>
>> getFoo: bar baz: baz
>>   <get>
>>   <path: '/foo?bar={bar}'>
>>   | baz |
>>   baz := self requestContext request at: 'baz' ifAbsent: [ nil ]
>
> Hi Philippe
>
> That was how I was attempting to get around it but it fails the path match
> if you add baz to the url.

Interesting, in that case you'll have to make two methods.

Cheers
Philippe
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Seaside REST optional query parameters

xx397
On 24/03/2013 21:12, Philippe Marschall wrote:

> On Sun, Mar 24, 2013 at 5:01 PM, Chris <[hidden email]> wrote:
>> On 24/03/2013 14:55, Philippe Marschall wrote:
>>> On Sun, Mar 24, 2013 at 1:08 PM, Chris <[hidden email]> wrote:
>>>> Does SeasideREST support optional query parameters so that you only have
>>>> to
>>>> write the one handler?
>>>>
>>>> i.e.
>>>> getFoo: bar baz: baz
>>>> <get>
>>>> <path: '/foo?bar={bar}&baz={baz}'>
>>>>
>>>> and the baz variable is nil if the user just navigates to /foo?bar=1.
>>>>
>>>> Currently it won't match the path handler. There is a mention on the
>>>> quick
>>>> start about how some of the more complicated matching techniques can be
>>>> applied to the query arguments but I can't see how to do it. Is it
>>>> possible
>>>> to use regex?
>>> No, there isn't right now. But you can fake it by removing the
>>> optional arguments from the pragma and manually looking them up.
>>>
>>> getFoo: bar baz: baz
>>>    <get>
>>>    <path: '/foo?bar={bar}'>
>>>    | baz |
>>>    baz := self requestContext request at: 'baz' ifAbsent: [ nil ]
>> Hi Philippe
>>
>> That was how I was attempting to get around it but it fails the path match
>> if you add baz to the url.
> Interesting, in that case you'll have to make two methods.
I would, but I'd quite like to support pagination and field filtering
which comes with 3 optional parameters and then if you add a couple more
for actual querying, the permutations could get out of control very
quickly! Is there anything simple that could be done so it could at
least match /foo?* Then it would still be possible to use the
requestContext request at: approach

Thanks
Chris
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Seaside REST optional query parameters

Philippe Marschall
On Sun, Mar 24, 2013 at 11:13 PM, Chris <[hidden email]> wrote:

> On 24/03/2013 21:12, Philippe Marschall wrote:
>>
>> On Sun, Mar 24, 2013 at 5:01 PM, Chris <[hidden email]> wrote:
>>>
>>> On 24/03/2013 14:55, Philippe Marschall wrote:
>>>>
>>>> On Sun, Mar 24, 2013 at 1:08 PM, Chris <[hidden email]> wrote:
>>>>>
>>>>> Does SeasideREST support optional query parameters so that you only
>>>>> have
>>>>> to
>>>>> write the one handler?
>>>>>
>>>>> i.e.
>>>>> getFoo: bar baz: baz
>>>>> <get>
>>>>> <path: '/foo?bar={bar}&baz={baz}'>
>>>>>
>>>>> and the baz variable is nil if the user just navigates to /foo?bar=1.
>>>>>
>>>>> Currently it won't match the path handler. There is a mention on the
>>>>> quick
>>>>> start about how some of the more complicated matching techniques can be
>>>>> applied to the query arguments but I can't see how to do it. Is it
>>>>> possible
>>>>> to use regex?
>>>>
>>>> No, there isn't right now. But you can fake it by removing the
>>>> optional arguments from the pragma and manually looking them up.
>>>>
>>>> getFoo: bar baz: baz
>>>>    <get>
>>>>    <path: '/foo?bar={bar}'>
>>>>    | baz |
>>>>    baz := self requestContext request at: 'baz' ifAbsent: [ nil ]
>>>
>>> Hi Philippe
>>>
>>> That was how I was attempting to get around it but it fails the path
>>> match
>>> if you add baz to the url.
>>
>> Interesting, in that case you'll have to make two methods.
>
> I would, but I'd quite like to support pagination and field filtering which
> comes with 3 optional parameters and then if you add a couple more for
> actual querying, the permutations could get out of control very quickly! Is
> there anything simple that could be done so it could at least match /foo?*
> Then it would still be possible to use the requestContext request at:
> approach

You can try to comment out the guard at the beginning of

WAComplexRoute >> #matchesParameters:

Cheers
Philippe
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Seaside REST optional query parameters

xx397
On 25/03/2013 21:36, Philippe Marschall wrote:

> On Sun, Mar 24, 2013 at 11:13 PM, Chris <[hidden email]> wrote:
>> On 24/03/2013 21:12, Philippe Marschall wrote:
>>> On Sun, Mar 24, 2013 at 5:01 PM, Chris <[hidden email]> wrote:
>>>> On 24/03/2013 14:55, Philippe Marschall wrote:
>>>>> On Sun, Mar 24, 2013 at 1:08 PM, Chris <[hidden email]> wrote:
>>>>>> Does SeasideREST support optional query parameters so that you only
>>>>>> have
>>>>>> to
>>>>>> write the one handler?
>>>>>>
>>>>>> i.e.
>>>>>> getFoo: bar baz: baz
>>>>>> <get>
>>>>>> <path: '/foo?bar={bar}&baz={baz}'>
>>>>>>
>>>>>> and the baz variable is nil if the user just navigates to /foo?bar=1.
>>>>>>
>>>>>> Currently it won't match the path handler. There is a mention on the
>>>>>> quick
>>>>>> start about how some of the more complicated matching techniques can be
>>>>>> applied to the query arguments but I can't see how to do it. Is it
>>>>>> possible
>>>>>> to use regex?
>>>>> No, there isn't right now. But you can fake it by removing the
>>>>> optional arguments from the pragma and manually looking them up.
>>>>>
>>>>> getFoo: bar baz: baz
>>>>>     <get>
>>>>>     <path: '/foo?bar={bar}'>
>>>>>     | baz |
>>>>>     baz := self requestContext request at: 'baz' ifAbsent: [ nil ]
>>>> Hi Philippe
>>>>
>>>> That was how I was attempting to get around it but it fails the path
>>>> match
>>>> if you add baz to the url.
>>> Interesting, in that case you'll have to make two methods.
>> I would, but I'd quite like to support pagination and field filtering which
>> comes with 3 optional parameters and then if you add a couple more for
>> actual querying, the permutations could get out of control very quickly! Is
>> there anything simple that could be done so it could at least match /foo?*
>> Then it would still be possible to use the requestContext request at:
>> approach
> You can try to comment out the guard at the beginning of
>
> WAComplexRoute >> #matchesParameters:

Thanks, it worked :) I'll let you know if there are any side effects

Chris
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside