On 2005-11-02 14:53:55 -0500, Jeff Watkins wrote: > > ImagePlacements > --------------- > article_id: Article > image_id: Image > source_name: String > > This would allow me to have the following in my data model: > > a= Article.get(1) > mainImage= a.imagePlacements["main"] > featureImage= a.imagePlacements["feature"] > > This simply can't be done with SQLObject today.
class Article(SQLObject):
title = StringCol(length=256)
images = MultipleJoin('ImagePlacement')
def imagePlacement(self,source_name):
return
ImagePlacement.selectBy(article=self,source_name=source_name)[0].image
class Image(SQLObject):
src = StringCol(length=256)
articles = MultipleJoin('ImagePlacement')
class ImagePlacement(SQLObject):
article = ForeignKey('Article')
image = ForeignKey('Image')
source_name = StringCol(length=256)
then you can do:
a = Article.get(1)
mainImage = a.imagePlacement("main")
featureImage = a.imagePlacement("feature")
--
anders pearson : http://www.columbia.edu/~anders/
C C N M T L : http://www.ccnmtl.columbia.edu/
weblog : http://thraxil.org/
pgp4HuG0mqwgp.pgp
Description: PGP signature

