REST-ful urls

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

REST-ful urls

John Thornborrow
Hello all,

I am currently creating a web-app that will use REST-ful urls for page
identification, allowing users to use direct urls for pages, rather than
every new session starting at the main page.

Currently I have employed a method akin to that of Apache's Rewrite. For
example, I can enter the url:
http://localhost:9090/seaside/pinesoft/blog to directly access the blog
section of my site. However, when I do so, the link will change (due to
Seasides 'double page load') back to
http://localhost:9090/seaside/pinesoft?_k=foo&_s=bar.

I have been looking through the codebase, trying to find where I can
update the url value to keep the original value but have not been able
to find anything of particular use.

Currently I am using the override of #initialRequest: on my root
component to decipher the url and depict which process I am to invoke
for the page. This works fine, with the exception of the url reverting.
Does anyone have any information as to how I may be able to maintain the
url state?

Thanks,
John.
www.pinesoft.co.uk


Pinesoft Computers are registered in England, Registered number: 2914825. Registered office: 266-268 High Street, Waltham Cross, Herts, EN8 7EA



This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com

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

Re: REST-ful urls

Lukas Renggli
> I have been looking through the codebase, trying to find where I can
> update the url value to keep the original value but have not been able
> to find anything of particular use.

To update the url look for #updateUrl: Sorry, I couldn't resist ;-)

> Currently I am using the override of #initialRequest: on my root
> component to decipher the url and depict which process I am to invoke
> for the page. This works fine, with the exception of the url reverting.

Have a look at other implementors of #initialRequest:, they mostly
also implement #updateRoot: in a appropriate way. For example
WABrowser does so and comes with Seaside.

<advert >There is also Pier that allows you to put content, files,
Seaside components (such as a ready made blog) and Seaside
applications at RESTful URLs without writing a single line of
code.</advert>

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: REST-ful urls

John Thornborrow
Sorry, my bad - I forgot to mention I am using #updateUrl: on my
components, such as the blog component adds "/blog" to the url - but it
still does not maintain it.

It *does* add it when I click a link (within my application) to my blog,
but not when I browse directly to it.

Will have a look around - I have Pier also, but didn't see anything
immediately identifiable as applicable to REST-ful urls.

Thanks,
John.

www.pinesoft.co.uk

Lukas Renggli wrote:

>> I have been looking through the codebase, trying to find where I can
>> update the url value to keep the original value but have not been able
>> to find anything of particular use.
>
> To update the url look for #updateUrl: Sorry, I couldn't resist ;-)
>
>> Currently I am using the override of #initialRequest: on my root
>> component to decipher the url and depict which process I am to invoke
>> for the page. This works fine, with the exception of the url reverting.
>
> Have a look at other implementors of #initialRequest:, they mostly
> also implement #updateRoot: in a appropriate way. For example
> WABrowser does so and comes with Seaside.
>
> <advert >There is also Pier that allows you to put content, files,
> Seaside components (such as a ready made blog) and Seaside
> applications at RESTful URLs without writing a single line of
> code.</advert>
>
> Lukas
>



Pinesoft Computers are registered in England, Registered number: 2914825. Registered office: 266-268 High Street, Waltham Cross, Herts, EN8 7EA



This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com

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

Re: REST-ful urls

Lukas Renggli
> Sorry, my bad - I forgot to mention I am using #updateUrl: on my
> components, such as the blog component adds "/blog" to the url - but it
> still does not maintain it.

Strange, then there must be a bug somewhere. Can you post some code?

> It *does* add it when I click a link (within my application) to my blog,
> but not when I browse directly to it.

Check WABrowser. This example uses the same technique.

> Will have a look around - I have Pier also, but didn't see anything
> immediately identifiable as applicable to REST-ful urls.

It is a bit more complicated there, as it comes from the time where
there was no #initialRequest:. If I find the time it would be maybe
good to simplify it a little bit ;-)

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: REST-ful urls

John Thornborrow
Good Morning, I hope  a pleasant weekend was had by all.

Here is where my application loads the components from #initialRequest:

---
initialRequest: aRequest
    | url controller |
    super initialRequest: aRequest.
    url _ aRequest url copyFrom: (self defaultPath size) to: (aRequest
url size).
    controller _ PineSoftWebController new uri: url.
    self registry at: 'content' put: (self call: controller)
---

and the #updateUrl: method from is also on my root component, but
accesses the sub-component for the value:

---
updateUrl: aUrl
    aUrl addToPath: self content url
---

I shall try adding the #updateUrl: method to my sub-component for a test
now - but I'm 99% sure this behaviour was also prevailent when I did it
before.

John

www.pinesoft.co.uk

Lukas Renggli wrote:

>> Sorry, my bad - I forgot to mention I am using #updateUrl: on my
>> components, such as the blog component adds "/blog" to the url - but it
>> still does not maintain it.
>
> Strange, then there must be a bug somewhere. Can you post some code?
>
>> It *does* add it when I click a link (within my application) to my blog,
>> but not when I browse directly to it.
>
> Check WABrowser. This example uses the same technique.
>
>> Will have a look around - I have Pier also, but didn't see anything
>> immediately identifiable as applicable to REST-ful urls.
>
> It is a bit more complicated there, as it comes from the time where
> there was no #initialRequest:. If I find the time it would be maybe
> good to simplify it a little bit ;-)
>
> Lukas
>



Pinesoft Computers are registered in England, Registered number: 2914825. Registered office: 266-268 High Street, Waltham Cross, Herts, EN8 7EA



This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com

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

Re: REST-ful urls

Lukas Renggli
>     self registry at: 'content' put: (self call: controller)

I don't understand what you put into that dictionary? #call: does not
return immediately and will break the initialization of your session.
I guess this is also the reason for the strange behavior you encounter
with the URL.

If I understand your intention correctly, this should be written as:

    self registry at: 'content' put: controller.
    self show: controller.

> updateUrl: aUrl
>     aUrl addToPath: self content url

Don't forget to call super, just in case ...

Lukas
--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: REST-ful urls

John Thornborrow
The #controller returns an instance of my own-made controller class.
This class returns (via #answer:) an instance of the subcomponent to be
rendered.
The dictionary is simply a registry, within my
RootClass>>#renderContentOn: method, I use:

---
html render: (self registry at: 'content')
---

I did not know it broke initialisation! I thought that would only happen
if I called #isolate: like so:

---
self isolate: [
    self call: controller]
---

Thanks,
John

www.pinesoft.co.uk

Lukas Renggli wrote:

>>     self registry at: 'content' put: (self call: controller)
>
> I don't understand what you put into that dictionary? #call: does not
> return immediately and will break the initialization of your session.
> I guess this is also the reason for the strange behavior you encounter
> with the URL.
>
> If I understand your intention correctly, this should be written as:
>
>    self registry at: 'content' put: controller.
>    self show: controller.
>
>> updateUrl: aUrl
>>     aUrl addToPath: self content url
>
> Don't forget to call super, just in case ...
>
> Lukas



Pinesoft Computers are registered in England, Registered number: 2914825. Registered office: 266-268 High Street, Waltham Cross, Herts, EN8 7EA



This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com

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

Re: REST-ful urls

John Thornborrow
I've removed the self call: invoke and it now works beatifully.

Just for reference; I've changed to this:

---
initialRequest: aRequest
    | url controller |
    super initialRequest: aRequest.
    url _ aRequest url copyFrom: (self defaultPath size) to: (aRequest
url size).
    controller _ PineSoftWebController new uri: url.
    self registry at: 'content' put: controller go.
---

Many thanks,

John.
www.pinesoft.co.uk

John Thornborrow wrote:

> The #controller returns an instance of my own-made controller class.
> This class returns (via #answer:) an instance of the subcomponent to be
> rendered.
> The dictionary is simply a registry, within my
> RootClass>>#renderContentOn: method, I use:
>
> ---
> html render: (self registry at: 'content')
> ---
>
> I did not know it broke initialisation! I thought that would only happen
> if I called #isolate: like so:
>
> ---
> self isolate: [
>     self call: controller]
> ---
>
> Thanks,
> John
>
> www.pinesoft.co.uk
>
> Lukas Renggli wrote:
>  
>>>     self registry at: 'content' put: (self call: controller)
>>>      
>> I don't understand what you put into that dictionary? #call: does not
>> return immediately and will break the initialization of your session.
>> I guess this is also the reason for the strange behavior you encounter
>> with the URL.
>>
>> If I understand your intention correctly, this should be written as:
>>
>>    self registry at: 'content' put: controller.
>>    self show: controller.
>>
>>    
>>> updateUrl: aUrl
>>>     aUrl addToPath: self content url
>>>      
>> Don't forget to call super, just in case ...
>>
>> Lukas
>>    
>
>
>
> Pinesoft Computers are registered in England, Registered number: 2914825. Registered office: 266-268 High Street, Waltham Cross, Herts, EN8 7EA
>
>
>
> This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com
>
> _______________________________________________
> 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
Reply | Threaded
Open this post in threaded view
|

Re: REST-ful urls

John Thornborrow
Oh, and I also update the #go method to return directly rather than use
#answer:

John Thornborrow wrote:

> I've removed the self call: invoke and it now works beatifully.
>
> Just for reference; I've changed to this:
>
> ---
> initialRequest: aRequest
>     | url controller |
>     super initialRequest: aRequest.
>     url _ aRequest url copyFrom: (self defaultPath size) to: (aRequest
> url size).
>     controller _ PineSoftWebController new uri: url.
>     self registry at: 'content' put: controller go.
> ---
>
> Many thanks,
>
> John.
> www.pinesoft.co.uk
>
> John Thornborrow wrote:
>  
>> The #controller returns an instance of my own-made controller class.
>> This class returns (via #answer:) an instance of the subcomponent to be
>> rendered.
>> The dictionary is simply a registry, within my
>> RootClass>>#renderContentOn: method, I use:
>>
>> ---
>> html render: (self registry at: 'content')
>> ---
>>
>> I did not know it broke initialisation! I thought that would only happen
>> if I called #isolate: like so:
>>
>> ---
>> self isolate: [
>>     self call: controller]
>> ---
>>
>> Thanks,
>> John
>>
>> www.pinesoft.co.uk
>>
>> Lukas Renggli wrote:
>>  
>>    
>>>>     self registry at: 'content' put: (self call: controller)
>>>>      
>>>>        
>>> I don't understand what you put into that dictionary? #call: does not
>>> return immediately and will break the initialization of your session.
>>> I guess this is also the reason for the strange behavior you encounter
>>> with the URL.
>>>
>>> If I understand your intention correctly, this should be written as:
>>>
>>>    self registry at: 'content' put: controller.
>>>    self show: controller.
>>>
>>>    
>>>      
>>>> updateUrl: aUrl
>>>>     aUrl addToPath: self content url
>>>>      
>>>>        
>>> Don't forget to call super, just in case ...
>>>
>>> Lukas
>>>    
>>>      
>>
>> Pinesoft Computers are registered in England, Registered number: 2914825. Registered office: 266-268 High Street, Waltham Cross, Herts, EN8 7EA
>>
>>
>>
>> This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com
>>
>> _______________________________________________
>> 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
>
>
>  
>
>  

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

Re: REST-ful urls

Lukas Renggli
In reply to this post by John Thornborrow
> The #controller returns an instance of my own-made controller class.

What is a controller class? A component?

> This class returns (via #answer:) an instance of the subcomponent
> to be rendered.

You seem to use #call: and #answer: where you should use plain
Smalltalk message send and return. Even-tough #call: and #answer:
mimic the Smalltalk send/return, it has completely different
semantics. Unless you want to display a component and return an answer
from an end-user interaction, never use #call: and #answer:.

Why not write something along:

    controller := PineSoftWebController new uri: url.
    self registry at: 'content' put: controller currentComponent

> I did not know it broke initialisation! I thought that would only happen
> if I called #isolate: like so:
>
> ---
> self isolate: [
>     self call: controller]

#isolate: is to control the use of the back-button in a control flow,
where multiple components are displayed in sequenze. You find in-depth
explanation about the semantics and the use of #call:, #answer: and
#isolate in "Seaside – A Multiple Control Flow Web Application
Framework" [1]

Lukas

[1] http://www.iam.unibe.ch/~scg/Archive/Papers/Duca04eSeaside.pdf

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: REST-ful urls

John Thornborrow
Lukas Renggli wrote:
>> The #controller returns an instance of my own-made controller class.
>
> What is a controller class? A component?
No, it is my implementation of a Controller (pattern) which interprets
the URL and returns the relevant component for rendering. It doesn't do
anything else.

>
>> This class returns (via #answer:) an instance of the subcomponent
>> to be rendered.
> You seem to use #call: and #answer: where you should use plain
> Smalltalk message send and return. Even-tough #call: and #answer:
> mimic the Smalltalk send/return, it has completely different
> semantics. Unless you want to display a component and return an answer
> from an end-user interaction, never use #call: and #answer:.
>
> Why not write something along:
>
>    controller := PineSoftWebController new uri: url.
>    self registry at: 'content' put: controller currentComponent
>
That is what I have now done, you are correct that I was using
#call:/#answer: unnecessarily.

>> I did not know it broke initialisation! I thought that would only happen
>> if I called #isolate: like so:
>>
>> ---
>> self isolate: [
>>     self call: controller]
>
> #isolate: is to control the use of the back-button in a control flow,
> where multiple components are displayed in sequenze. You find in-depth
> explanation about the semantics and the use of #call:, #answer: and
> #isolate in "Seaside – A Multiple Control Flow Web Application
> Framework" [1]
>
> Lukas
>
> [1] http://www.iam.unibe.ch/~scg/Archive/Papers/Duca04eSeaside.pdf
>
Thanks, I shall have a read.

John

www.pinesoft.co.uk


Pinesoft Computers are registered in England, Registered number: 2914825. Registered office: 266-268 High Street, Waltham Cross, Herts, EN8 7EA



This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com

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

Re: REST-ful urls

John Thornborrow
I have stumbled upon a similar problem after I have changed sessions to
use cookies (i.e. WASessionConfiguration>>>useSessions returns true)

The same symptoms are occuring; the user can enter the /blog url and it
will display the blog, but the url will revert. Does anyone know the cause?

Many thanks,

John

www.pinesoft.co.uk

John Thornborrow wrote:

> Lukas Renggli wrote:
>  
>>> The #controller returns an instance of my own-made controller class.
>>>      
>> What is a controller class? A component?
>>    
> No, it is my implementation of a Controller (pattern) which interprets
> the URL and returns the relevant component for rendering. It doesn't do
> anything else.
>  
>>> This class returns (via #answer:) an instance of the subcomponent
>>> to be rendered.
>>>      
>> You seem to use #call: and #answer: where you should use plain
>> Smalltalk message send and return. Even-tough #call: and #answer:
>> mimic the Smalltalk send/return, it has completely different
>> semantics. Unless you want to display a component and return an answer
>> from an end-user interaction, never use #call: and #answer:.
>>
>> Why not write something along:
>>
>>    controller := PineSoftWebController new uri: url.
>>    self registry at: 'content' put: controller currentComponent
>>
>>    
> That is what I have now done, you are correct that I was using
> #call:/#answer: unnecessarily.
>  
>>> I did not know it broke initialisation! I thought that would only happen
>>> if I called #isolate: like so:
>>>
>>> ---
>>> self isolate: [
>>>     self call: controller]
>>>      
>> #isolate: is to control the use of the back-button in a control flow,
>> where multiple components are displayed in sequenze. You find in-depth
>> explanation about the semantics and the use of #call:, #answer: and
>> #isolate in "Seaside – A Multiple Control Flow Web Application
>> Framework" [1]
>>
>> Lukas
>>
>> [1] http://www.iam.unibe.ch/~scg/Archive/Papers/Duca04eSeaside.pdf
>>
>>    
> Thanks, I shall have a read.
>
> John
>
> www.pinesoft.co.uk
>
>
> Pinesoft Computers are registered in England, Registered number: 2914825. Registered office: 266-268 High Street, Waltham Cross, Herts, EN8 7EA
>
>
>
> This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com
>
> _______________________________________________
> 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
Reply | Threaded
Open this post in threaded view
|

Re: REST-ful urls

John Thornborrow
Correction to my previous message, the method is:
WASessionConfiguration>>>useSessionCookie

John

www.pinesoft.co.uk

John Thornborrow wrote:

> I have stumbled upon a similar problem after I have changed sessions to
> use cookies (i.e. WASessionConfiguration>>>useSessions returns true)
>
> The same symptoms are occuring; the user can enter the /blog url and it
> will display the blog, but the url will revert. Does anyone know the cause?
>
> Many thanks,
>
> John
>
> www.pinesoft.co.uk
>
> John Thornborrow wrote:
>  
>> Lukas Renggli wrote:
>>  
>>    
>>>> The #controller returns an instance of my own-made controller class.
>>>>      
>>>>        
>>> What is a controller class? A component?
>>>    
>>>      
>> No, it is my implementation of a Controller (pattern) which interprets
>> the URL and returns the relevant component for rendering. It doesn't do
>> anything else.
>>  
>>    
>>>> This class returns (via #answer:) an instance of the subcomponent
>>>> to be rendered.
>>>>      
>>>>        
>>> You seem to use #call: and #answer: where you should use plain
>>> Smalltalk message send and return. Even-tough #call: and #answer:
>>> mimic the Smalltalk send/return, it has completely different
>>> semantics. Unless you want to display a component and return an answer
>>> from an end-user interaction, never use #call: and #answer:.
>>>
>>> Why not write something along:
>>>
>>>    controller := PineSoftWebController new uri: url.
>>>    self registry at: 'content' put: controller currentComponent
>>>
>>>    
>>>      
>> That is what I have now done, you are correct that I was using
>> #call:/#answer: unnecessarily.
>>  
>>    
>>>> I did not know it broke initialisation! I thought that would only happen
>>>> if I called #isolate: like so:
>>>>
>>>> ---
>>>> self isolate: [
>>>>     self call: controller]
>>>>      
>>>>        
>>> #isolate: is to control the use of the back-button in a control flow,
>>> where multiple components are displayed in sequenze. You find in-depth
>>> explanation about the semantics and the use of #call:, #answer: and
>>> #isolate in "Seaside – A Multiple Control Flow Web Application
>>> Framework" [1]
>>>
>>> Lukas
>>>
>>> [1] http://www.iam.unibe.ch/~scg/Archive/Papers/Duca04eSeaside.pdf
>>>
>>>    
>>>      
>> Thanks, I shall have a read.
>>
>> John
>>
>> www.pinesoft.co.uk
>>
>>
>> Pinesoft Computers are registered in England, Registered number: 2914825. Registered office: 266-268 High Street, Waltham Cross, Herts, EN8 7EA
>>
>>
>>
>> This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com
>>
>> _______________________________________________
>> 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
>
>
>  
>
>  

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

Re: REST-ful urls

Lukas Renggli
> Correction to my previous message, the method is:
> WASessionConfiguration>>>useSessionCookie

That's very likely a bug in Seaside. Seaside does an additional
redirect to ensure that cookies are supported and probably looses the
URL then. Please file a bug-report in the Seaside category on
bugs.squeak.org.

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside