On Thu, 14 Dec 2006 00:35:55 +0300, Oleg Broytmann hath writ:
> On Wed, Dec 13, 2006 at 03:56:15PM -0500, Dan Lenski wrote:
>> How would I now find out the active roles, given a User instance?
> 
>    You can do it in Python:
> user = User.get(id)
> active_roles = [role for role in user.roles if role.active]
>    The solution should be good enough because I don't expect there are too
> many roles for a user.

Thanks Oleg.  Unfortunately, this doesn't seem to work.  Given the schema
of the example:
  user = User.get(1)
  active_roles = [role for role in user.roles if role.active] =>
  AttributeError: 'Role' object has no attribute 'active'

Which makes sense to me, I guess.  'active' isn't a property of the Role
object *OR* the User object.  It's a property of the association between
the two.

Maybe I'm thinking too hard about this, but I can't seem to
figure out how to access the 'active' field given the User and ROle
objects.

Dan


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to