Since a beer can only be made by one brewery (i.e. beer has a foreign
key for brewery) the short names don't have to be unique.  Both Beer
and Brewery could have the property "shortname".

Lets take your example:  /beers/dogfish/midastouch

A brewery should only produce one beer with the short name of
"midastouch".  You would simply have the first part of the url load
the dogfish brewery object.  You can then do:

--code--

beer = None
for loopBeer in brewery.beers:
    if loopBeer.shortname == passedBeerShortname:
        beer = loopBeer

if beer:
    # display stuff
else:
    # show an error

--/code--

Of course, there's quite a bit that needs to go on before the loop
like extracting the args from the url and loading the brewery object,
but you get the idea.

With this method, beer.shortname doesn't have to be unique in the
database as the combination of brewery.shortname and beer.shortname
creates a unique key programatically.

Regards,

Lee




On 20/10/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> then just set breweryname as UNIQUE.
>
> Serge Wroclawski wrote:
> > On 10/20/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > >
> > >
> > > Do you really need AlternativeID like this ?
> >
> >
> >
> > Well Brewery must be...
> >
> > If you have /beers/breweryname/beername then breweryname must be unique.
> >
> > beername must be unique to brewery, but you're right in that with SQLObject,
> > I can overload the setting of beer.shortname to require uniqueness to the
> > brewery.
> >
> > This is why I'm asking you folks, since you understand the software better
> > than I do.
> >
> > - Serge Wroclawski
>
>

Reply via email to