Hi all
I have situation that i have table with relation many-to-many and use 
method add (so it looks like in manual e.g.
class User(SQLObject):
...     class sqlmeta:
...         table = "user_table"
...     username = StringCol(alternateID=True, length=20)
...     roles = RelatedJoin('Role',addRemoveName='UserRoles')
class Role(SQLObject):
...     name = StringCol(alternateID=True, length=20)
...     users = RelatedJoin('User')
so if I want to give a user role i just do: UserObject.addUserRoles 
and everything looks perfect but sometimes I give one user the same 
roles few times. I put indexex in database and after i run again my 
aplication i start to get nice traceback. So what is the best way to 
write and use method addUserRole that:
1 first check is that user does'n have that role 
2 second - - if user has this role method do nothing else user get 
new role
For now when i had database with indexes I use 
try:
  user.addaddUserRoles
except:
   pass
but this doesn't looks nice and maybe there is a better way.
Thanks for any help
Gregor

----------------------------------------------------
Jak zerwać z dziewczyną, która potrafi fruwać, przenosić 
góry i przebijać wzrokiem stalowe pancerze? Uma Thurman
w komedii "MOJA SUPER EKSDZIEWCZYNA". Już kinach!
http://klik.wp.pl/?adr=http%3A%2F%2Fadv.reklama.wp.pl%2Fas%2Fmojasuperdziewczyna.html&sid=857



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to