Re: [SQLObject] Objects with localized properties
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: Luke O. <lu...@me...> - 2003-05-07 20:35:23
|
> Yes, that's probably an easier layout too. In this case a join
> doesn't
> seem quite right... hmmm... you might do:
>
> class Product(SQLObject):
> _joins = [MultipleJoin('ProductName')]
>
> def name(self, lang):
> return ProductName.selectBy(
> productID=self.id, lang=lang)[0].name
This leads me to a vague desire I've had for a while: to be able to do
selects over joins (really, a filter). Conceptually, something
equivalent to:
def name(self, lang):
return [ x for x in self.productNames if x.lang == lang ][0]
although I'd like a cleaner way to add the condition.
def name(self, lang):
return self.productNamesWhere(q.lang == lang)[0]
except this gets into the mess (which i don't entirely mind) of the
SelectResults system...
Just some thoughts for down the road. I find my self wanting to filter
joins on a regular basis, and end up doing conditional list
comprehensions like my first example (sql equiv 'where publish <> 0',
etc), but wonder if its worth working it into the core.
- Luke
|