Hi,
Ian has a point there, one of the reason Hibernate is doing so much,
is partly because writing logic in Java is not as fun as doing it in
Python, so doing as much as possible in a declarative way is
reasonable in the J2EE world.
Cheers
Ronald
On Nov 2, 2005, at 9:06 PM, Ian Bicking wrote:
Jeff Watkins wrote:
What I'm looking for specifically (and what I really enjoyed in
Hibernate, which in my book sets the standard for ORMs if you
hadn't already guessed) was something like the following:
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.
Sure it can. It requires programming. Programming is okay; we're
all programmers, right? Not everything needs to be declarative.
class Article(SQLObject):
def imagePlacements(self, name):
res = list(ImagePlacements.selectBy(article=self,
source_name=name))
assert len(res) == 1
return res[0].image
Well, that's not ['main'], but instead ('main'). Implementing the
full dictionary interface would be nice, but a bit more work (not
much, UserDict.DictMixin handles most of the methods). I'd like
SelectResults instances (what selectBy returns) to have a getOne()
method too, which would handle the assert and whatnot.
A join along these lines would be okay to have; I don't want to
bring in *every* possible case as a declarative construct, but
there's certainly room for a few more. The API might be:
imagePlacements = joins.MappingJoin('ImagePlacements',
keyColumn='sourceName', resultColumn='image')
--
Ian Bicking / [EMAIL PROTECTED] / http://blog.ianbicking.org
________________________________
Ronald Jaramillo
mail: ronald AT checkandshare DOT com
blog: http://www.checkandshare.com/blog