[squeak-dev] four Altitude questions

Colin Putney colin at wiresong.com
Fri Dec 14 02:15:53 UTC 2012


On Thu, Dec 13, 2012 at 7:51 PM, Chris Cunnington <
smalltalktelevision at gmail.com> wrote:


> 1. ALRestfulLocator>>paths "Vat does dis do?" I don't see anything
> accessing this dictionary.
>

It's mainly used in #urlForResource:. It's badly named, though, so I've
just committed a fix. It's now called "urls".

The job of a locator is to map URLs to resources and the reverse, resources
to URLs. ALRestfulLocator does this in such a way that the urls can be
arbitrary, and you'll always get the same URL for semantically equivalent
resources. (Consistent urls are required for REST.)

When the locator receives #urlForResource: it calculates a "key" for that
resource, by serializing it and hashing the bytes.
Then it checks to see if a url has already been assigned to that key. If
so, great, answer it. If not, it asks its url strategy to create one. Since
this is a resource we haven't seen before, we store the url-> mapping. The
resources instance variable maps urls to resources, and the urls instance
variable (formerly called paths) maps keys to URLs. Once the mapping is
stored, #urlForResource: and #resourceForUrl: just do dictionary lookups.

2. An auth/storage relay example, please.
>

Yeah, working on it. AL-Storage contains ALStorageRelay, which is mostly
working now and generates ETag headers for resources based on domain model
objects stored in an ALRepository. Auth isn't implemented yet.


> 3. ALNotFound:/favicon.ico now shows up with every click.
>

Are you getting 404 responses? If so, you just need to create a resource at
that url. If not, it's a bug in Altitude.

Something like in your #initializeLocator method:

locator
    at: (ALPath / 'favicon.ico')
    put: (ALFileResource on: (FSLocator imageDirectory / 'favicon.ico'))

4. Why there are random urls?
>

As I mentioned above, the urls that ALRestfulLocator generates can be
anything. This is why we can set up an image a file resource at
/favicon.ico, which is hardcoded into browsers. It also means that when we
generate urls automatically, we can use whatever scheme we want. This is
what ALUrlStategy subclasses are for:

ALSequentialUrlStrategy generates urls in a predicable sequence: /1, /2, /3
etc. This is handy for testing. It might also be good for something like a
URL shortening service where the shortest possible URLs are desirable.

ALRandomUrlStrategy does the opposite. It generates pseudo-random
unguessable URLs. That makes a web application more secure.

ALDigestUrlStrategy provides a middle path between predictability and
unpredictability. It creates urls that are difficult to guess, but
consistent. So, for example, two different images running the same
application would generate the same urls for equivalent resources. (This
wouldn't be the case with random urls).

Colin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20121213/ae8c7619/attachment.htm


More information about the Squeak-dev mailing list