Dear all,

I'm using Elixir 0.5.2 with CherryPy 3 with the following model:

class Users(Entity):
    id = Field(Integer, primary_key=True)
    firstname = Field(String(30))
    lastname = Field(String(30))
    logname = Field(String(15))
    password = Field(String(35))
    email = Field(String(30))
    privilege = Field(String(1))
    supervisor = Field(Boolean)
    admin = ManyToMany('Users')

Using the following code I'm able to add one or more admin to each user
and remove more admin at the same time but if I try to remove only
one admin I receive "SQLError: list.remove(x): x not in list" but the
relation is removed!!. (data is a dictionary with the fields values
coming from a form. data['newRight'] can contains the ids of users that
has supervisor field=True and that I want to associate with the user,
data['removedRight'] can contains the ids of user supervisors that I
want to remove from the user). 

           if data['newRight']:
                super_ids=data['newRight'].split(',')
                u.admin=[]
                for s_id in super_ids:
                    if s_id:
                        admin = Users.query.get(s_id)
                        u.admin.append(admin)
                        u.update()
            if data['removedRight']:
                super_ids=data['removedRight'].split(',')             
                for s_id in super_ids:
                    if s_id:
                        adm = Users.query.get(s_id)
                        u.admin.remove(adm)
                        u.update()
            session.flush()


Someone can explain me where I wrong?

Thanks in advance.
-- 
-------------------------------------------------------------------
       (o_
(o_    //\  Coltivate Linux che tanto Windows si pianta da solo.
(/)_   V_/_
+------------------------------------------------------------------+
|     ENRICO MORELLI         |  email: [email protected]       |
| *     *       *       *    |  phone: +39 055 4574269             |
|  University of Florence    |  fax  : +39 055 4574253             |
|  CERM - via Sacconi, 6 -  50019 Sesto Fiorentino (FI) - ITALY    |
+------------------------------------------------------------------+

--~--~---------~--~----~------------~-------~--~----~
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