I am writing a toy app in TurboGears to learn it.
My toy app involves beer.
I have a class called Brewery:
class Brewery(SQLObject):
name = StringCol()
shortname = StringCol(alternateID = True, length = 32)
MultipleJoin("Beer")
...
and a class called Beer:
class Beer(SQLObject):
name = StringCol()
brewery = ForeignKey("Brewery")
...
and I'd like to have a shortname for beer, but to avoid the issue of
name clashes, what I really want is the shortname to be a concatination
of the brewery shortname with the beer shortname.
So, if the Brewery shortname is "dogfishhead" and the beer is Midas
Touch Golden Elixir, the shortname might be midastouch, but since there
might be a name clash with more simply named beers (ie two beers called
"Lager", I really want the unique part to be a combination of the two,
the brewery and the beer, as in something like dogfishhead-midastouch.
Further complicating things, though, if dogfishhead changes its name
(and therefore its shortname) to something else, I'd like to be able to
easily change the name in the unique string combination.
The reason, BTW that I want this, is so my app can do something clever like
http://localhost:8080/beers/dogfishhead/midastouch and
information on that beer would show up. The beer name doesn't have to
be unique, only unque to that brewery.
Does this idea make sense?
Is there something fundamental I'm missing about SQL, SQLObject or some other aspect of TurboGears that might do what I want?
I may have seen this type of example in the documentation, but I can't
find it now. If it's somewhere obvious, I appologize and ask that you
point me to it.
Any help would be appreciated,
- Serge Wroclawski
- [TurboGears] "Right" way to do combined Altern... Serge Wroclawski
- [TurboGears] Re: "Right" way to do combin... [EMAIL PROTECTED]
- [TurboGears] Re: "Right" way to do co... Serge Wroclawski
- [TurboGears] Re: "Right" way to d... [EMAIL PROTECTED]
- [TurboGears] Re: "Right" way ... Lee McFadden
- [TurboGears] Re: "Right" way to do combin... nichyoung

