Tons of rest ful url

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

Tons of rest ful url

Hilaire Fernandes-4
Hi!

Is it possible to generate thousand of restful url from a seaside
applicaton? (more like a catalog)
If so at which cost? and is it reliable in the long term?

Hilaire

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

signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Tons of rest ful url

Lukas Renggli
> Is it possible to generate thousand of restful url from a seaside
> applicaton? (more like a catalog)

Sure, in your root component you implement something along:

YourRootComponent>>initialRequest: aRequest
     | catalogId catalogItem |
     super initialRequest: aRequest.
     catalogId := aRequest url path last.
     catalogItem := self lookupInCatalog: catalogId.
     catelogItem isNil
          ifFalse: [ self show: (YourCatalogItemViewer on: catelogItem) ]

catalogId gets the last element of the request path assigned.

catalogItem and the method #lookupInCatalog: maps the above string to
an object. To get a restful application this method should always
return the same object for the same catalogId, otherwise your
application won't be restful.

> If so at which cost?

In the above example almost for free. You just have to maintain the
mapping from catalogId to your catalogItems. You can store millions of
such mappings in an external database, thousands within your image.

In fact you can create a truly infinite number of restful entry points
into an application at no cost if you create a smart implementation of
#lookupInCatalog: ;-)

> and is it reliable in the long term?

That's very reliable. Have a look at the google search results of my
website (http://www.google.com/search?q=site:lukas-renggli.ch). The
search result all identify uniquely objects through the restful URL
that live within an image on the server already for years.

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: Tons of rest ful url

Randal L. Schwartz
In reply to this post by Hilaire Fernandes-4
>>>>> "Hilaire" == Hilaire Fernandes <[hidden email]> writes:

Hilaire> Is it possible to generate thousand of restful url from a seaside
Hilaire> applicaton? (more like a catalog)

Yes.  Pier does this, by default.  Each added resource shows up
with its own URL.

Hilaire> If so at which cost?

Free. :)

Hilaire>  and is it reliable in the long term?

Apparently.

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[hidden email]> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Tons of rest ful url

Hilaire Fernandes-4
In reply to this post by Lukas Renggli
Ok, thanks for the tips.
Now I want to see if it is possible to get a little more ;)
Let's suppose my top level component is the view of an object A and I
want to build a meaningful and restful url based on A attributes like
name, version,....
The idea is the get url like /nomenclature/discipline-2007.html

Is it possible?

Hilaire

Le mardi 17 février 2009 à 17:13 +0100, Lukas Renggli a écrit :

> > Is it possible to generate thousand of restful url from a seaside
> > applicaton? (more like a catalog)
>
> Sure, in your root component you implement something along:
>
> YourRootComponent>>initialRequest: aRequest
>      | catalogId catalogItem |
>      super initialRequest: aRequest.
>      catalogId := aRequest url path last.
>      catalogItem := self lookupInCatalog: catalogId.
>      catelogItem isNil
>           ifFalse: [ self show: (YourCatalogItemViewer on: catelogItem) ]
>
> catalogId gets the last element of the request path assigned.
>
> catalogItem and the method #lookupInCatalog: maps the above string to
> an object. To get a restful application this method should always
> return the same object for the same catalogId, otherwise your
> application won't be restful.
>
> > If so at which cost?
>
> In the above example almost for free. You just have to maintain the
> mapping from catalogId to your catalogItems. You can store millions of
> such mappings in an external database, thousands within your image.
>
> In fact you can create a truly infinite number of restful entry points
> into an application at no cost if you create a smart implementation of
> #lookupInCatalog: ;-)
>
> > and is it reliable in the long term?
>
> That's very reliable. Have a look at the google search results of my
> website (http://www.google.com/search?q=site:lukas-renggli.ch). The
> search result all identify uniquely objects through the restful URL
> that live within an image on the server already for years.
>
> Lukas
>

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

signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Re: Tons of rest ful url

Lukas Renggli
> The idea is the get url like /nomenclature/discipline-2007.html
>
> Is it possible?

Sure, you just do a two step lookup. First you lookup your catalog
object using #lookupInCatalog: and then you lookup the attribute using
another method. Note that aRequest knows the complete request URL, so
you can for example look at its parameters using

     aRequest at: 'attribute'

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: Re: Tons of rest ful url

Hilaire Fernandes-4
I don't see where you build the url, or do I miss something?

Is the following article still correct with today Seaside ?
http://kentreis.wordpress.com/2007/06/28/meaningful-seaside-links-after-session-expiry/

Hilaire

Le mercredi 18 février 2009 à 08:58 +0100, Lukas Renggli a écrit :

> > The idea is the get url like /nomenclature/discipline-2007.html
> >
> > Is it possible?
>
> Sure, you just do a two step lookup. First you lookup your catalog
> object using #lookupInCatalog: and then you lookup the attribute using
> another method. Note that aRequest knows the complete request URL, so
> you can for example look at its parameters using
>
>      aRequest at: 'attribute'
>
> Lukas
>

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

signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Tons of rest ful url

Lukas Renggli
On Wed, Feb 18, 2009 at 9:03 AM, Hilaire Fernandes <[hidden email]> wrote:
> I don't see where you build the url, or do I miss something?

You were only asking about the lookup ;-)

Building the URL happens in #updateUrl:

Have a look at WABrowser for a complete example of the iteration
between #initialRequest: and #updateUrl:

Lukas

>
> Is the following article still correct with today Seaside ?
> http://kentreis.wordpress.com/2007/06/28/meaningful-seaside-links-after-session-expiry/
>
> Hilaire
>
> Le mercredi 18 février 2009 à 08:58 +0100, Lukas Renggli a écrit :
>> > The idea is the get url like /nomenclature/discipline-2007.html
>> >
>> > Is it possible?
>>
>> Sure, you just do a two step lookup. First you lookup your catalog
>> object using #lookupInCatalog: and then you lookup the attribute using
>> another method. Note that aRequest knows the complete request URL, so
>> you can for example look at its parameters using
>>
>>      aRequest at: 'attribute'
>>
>> Lukas
>>
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>



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