OK, may have found it. In the LHS of the relation,

adresses = OneToMany('Address', lazy='dynamic') enables this behaviour

so jack.adresses.filter(postcode == 123) is valid now (rather than
raising an exception about 'Instrumented List' has no filter attribute

Which is a bit less verbose, and readable.

Darren

On Wed, Feb 29, 2012 at 11:21 PM, Darren <[email protected]> wrote:
> Hi,
>
> I have a simple 1:many table relationship (say, user, adresses), and I
> can say thing like the following (syntax wrong, just psuedo code):
>
> jack = User(name="Jack")
> jack.addresess.append(Address(postcode=345)
> jack.addresess.append(Address(postcode=1234))
>
> Then working with jack, I can say things like
> jack.adresses[0] and get the first appended item, and [-1] to get last
> (not sure if this is guarateed), just like they were python lists
>
> To find address with postcode=345, I have to
>
> User.query.filter(....... messy filter to specify which user and post
> code)
>
> Is there a more natural (python) way where I can do a query on that
> list of jack.adresses, say:
>
> jack.adresses.query(postcode == 345)
> or
> jack.addresses.postcode[345]
>
> Thanks
>
> Darren
>
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"SQLElixir" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlelixir?hl=en.

Reply via email to