Excellent! Thank you Anthony this solved my problem. Also thank you for the
clear explanations :-)

*cheers


On Sun, Jan 12, 2014 at 6:05 AM, Anthony <abasta...@gmail.com> wrote:

> If these groups are for the purpose of controlling access to resources,
> you might consider using the built-in role-based access control available
> via Auth. You would create Auth groups and then assign users as members to
> groups. You could then use auth.has_membership() and
> @auth.requires_membership() to control access. If you must take your
> alternative approach, though...
>
> db.define_table('project_groups',
>>     ....
>>     Field('members', requires=IS_IN_DB(db, db.auth_user, '%(first_name)s
>> %(last_name)s %(public_email)s', multiple=(1, 1000)), default=auth.user_id,
>> writable=False, readable=False),
>>
>
> If you want to store a list of members in the "members" field, then you
> should make it a list:reference type field (since you didn't specify a
> field type above, it just defaults to a simple string field). Also, it
> doesn't make sense to default to auth.user_id, given that the field
> contains a list (the default must therefore be a list, though probably you
> don't want a default).
>
> # The query which is baffling me at this stage
>>
>>     elif request.args(0) == 'accept':
>>         #tmp = db((db.tmp.project_groups == db.project_groups.id) &
>> (db.project_groups.userinfo == auth.user_id)).select()
>>         tmp_user = request.args(1)
>>         tmp = db(db.tmp.source == tmp_user).select(db.tmp.ALL)
>>         updates = db(db.project_groups.id ==
>> db.tmp.project_groups).select(db.project_groups.ALL)
>>
>
> A given db.tmp record is for a single user requesting to join a single
> group, correct? In that case, only one record should be defined, so no need
> to create a loop. Instead, do:
>
>     update = db(db.project_groups.id == db.tmp.project_groups).select(db.
> project_groups.ALL).first()
>
>             myupdate.update(members = myupdate.members + [tmp_user])
>>
>
> Calling .update() on a Row object only updates the Row itself, not the
> database record. You want to use .update_record().
>
> Anthony
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to