Seaside-Rest question [WAS] Re: How can I make this kind of redirect in Seaside?

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

Seaside-Rest question [WAS] Re: How can I make this kind of redirect in Seaside?

Mariano Martinez Peck


On Tue, Jul 18, 2017 at 4:01 PM, Mariano Martinez Peck <[hidden email]> wrote:


On Tue, Jul 18, 2017 at 1:09 PM, Philippe Marschall <[hidden email]> wrote:
On Tue, Jul 18, 2017 at 4:02 PM, Mariano Martinez Peck
<[hidden email]> wrote:
> Hi guys,
>
> Ley's say I have a root component registered in /registration which takes
> care of user registration. Inside a callback of a button ('Register') I want
> to redirect to /reps (my real app prefix) which is associated to a different
> root task which renders the welcome/login window from which you enter to the
> app.
>
> What I want is to "auto-login" after register. So I need to make a redirect
> from /registration to /reps but auto-getting a session for that root task
> etc. I guess the way to do this is to simulate getting a session and make
> the redirect  to /reps_s=...
>
> Any ideas?

Maybe you can take some ideas from WARestfulComponentFilter >>
#startSessionWithRoot: you can use #rootComponent: switch the root
component.


Hi Philippe,

Thanks, that did work nicely. The only thing that took me some time to figure out is HOW to build the methods with the pragmas. There was no subclass of the filter as an example. I had to search lot in mailing lists until I come up with a working method example. I ended doing something like this:

userRegistration
<get>
<path: '/registration'>
self startSessionWithRoot: MyComponent new.



BTW... how can I allow something like this:

<path: '/companyreport/{ticker}/{reportName}'>
 
I then somehow I would like to parse the URL inside the method so that I answer the correct response based on the URL ...

Any idea?

Thanks,


--

_______________________________________________
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 question [WAS] Re: How can I make this kind of redirect in Seaside?

Esteban A. Maringolo
2017-07-18 19:57 GMT-03:00 Mariano Martinez Peck <[hidden email]>:

> BTW... how can I allow something like this:
>
> <path: '/companyreport/{ticker}/{reportName}'>
>
> I then somehow I would like to parse the URL inside the method so that I
> answer the correct response based on the URL ...


You should have a method like:

getTicker: ticker report: reportName
  <get>
  <path: '/companyreport/{ticker}/{reportName}'>

There you'll have the ticker and reportName placeHolders mapped to the
argument variable names. It is, the arguments of the method will hold
whatever you put in those placeholders.

But keep in mind this will only match a URI as a whole, if for some
reason you add query parameters to the request, like
'/companyreport/AAPL/dailyChange?format=csv', you'll need another
method, with another name and path pragma.

That's why I implemented the "variableQuery" pragma [1], so you can
have a fixed URI but variable queries mapped to a single smalltalk
method. But it was removed [2] because there was a proper way [3] of
implementing it I ignored/didn't understand at that time.

This part of the framework is powerful, but certainly lacking
examples, and without the behavior of [1] or [3] is too rigid for a
flexible API.

I could explain how it works, and use it as I do, but I can't tell I
completely understand it as probably its creator does.

Regards,

Esteban A. Maringolo

[1] http://forum.world.st/New-Seaside-REST-Core-extension-td4872995.html
[2] http://forum.world.st/REST-quot-variable-queries-quot-td4941376.html#a4941377
[3] http://lists.squeakfoundation.org/pipermail/seaside/2014-December/031314.html
_______________________________________________
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 question [WAS] Re: How can I make this kind of redirect in Seaside?

Mariano Martinez Peck


On Wed, Jul 19, 2017 at 9:43 AM, Esteban A. Maringolo <[hidden email]> wrote:
2017-07-18 19:57 GMT-03:00 Mariano Martinez Peck <[hidden email]>:

> BTW... how can I allow something like this:
>
> <path: '/companyreport/{ticker}/{reportName}'>
>
> I then somehow I would like to parse the URL inside the method so that I
> answer the correct response based on the URL ...


You should have a method like:

getTicker: ticker report: reportName
  <get>
  <path: '/companyreport/{ticker}/{reportName}'>

There you'll have the ticker and reportName placeHolders mapped to the
argument variable names. It is, the arguments of the method will hold
whatever you put in those placeholders.

But keep in mind this will only match a URI as a whole, if for some
reason you add query parameters to the request, like
'/companyreport/AAPL/dailyChange?format=csv', you'll need another
method, with another name and path pragma.

That's why I implemented the "variableQuery" pragma [1], so you can
have a fixed URI but variable queries mapped to a single smalltalk
method. But it was removed [2] because there was a proper way [3] of
implementing it I ignored/didn't understand at that time.

This part of the framework is powerful, but certainly lacking
examples, and without the behavior of [1] or [3] is too rigid for a
flexible API.

I could explain how it works, and use it as I do, but I can't tell I
completely understand it as probably its creator does.



Cool. Thank you very much Esteban. Very helpful and detailed response. 
Really appreciated,

 
Regards,

Esteban A. Maringolo

[1] http://forum.world.st/New-Seaside-REST-Core-extension-td4872995.html
[2] http://forum.world.st/REST-quot-variable-queries-quot-td4941376.html#a4941377
[3] http://lists.squeakfoundation.org/pipermail/seaside/2014-December/031314.html
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



--

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