This line

db.personal_uploads.file_upload.authorize = lambda record: auth.is_logged_in() 
and (record.members.contains(auth.user_id))


should be


db.personal_uploads.file_upload.authorize = lambda record: auth.user and 
auth.user.id in (record.members or [])


On Monday, 23 June 2014 13:26:20 UTC-5, Keri Sui wrote:
>
> Hello!
>
> I am trying to enable temporary access for users to downloadable files by 
> requesting access on a per file basis  
>
> In my database.
>
>
> Field('members', 'list:reference db.auth_user', default=auth.user_id, 
> requires=IS_IN_DB(db, db.auth_user, '%(first_name)s %(last_name)s 
> %(email)s', multiple=(1, 1000)), writable=False, readable=False),
>
> ...
>
>
> db.personal_uploads.file_upload.authorize = lambda record: 
> auth.is_logged_in() and (record.members.contains(auth.user_id))
>
> Causes the following error when trying to download the file:
>
> Traceback (most recent call last):
>   File "/home/www-data/web2py/gluon/restricted.py", line 220, in restricted
>     exec ccode in environment
>   File "/home/www-data/web2py/applications/cryaboutit/controllers/default.py" 
> <https://62.75.246.181/admin/edit/cryaboutit/controllers/default.py>, line 
> 328, in <module>
>   File "/home/www-data/web2py/gluon/globals.py", line 385, in <lambda>
>     self._caller = lambda f: f()
>   File "/home/www-data/web2py/gluon/cache.py", line 523, in wrapped_f
>     rtn = func()
>   File "/home/www-data/web2py/applications/cryaboutit/controllers/default.py" 
> <https://62.75.246.181/admin/edit/cryaboutit/controllers/default.py>, line 
> 298, in download
>     return response.download(request, db)
>   File "/home/www-data/web2py/gluon/globals.py", line 601, in download
>     (filename, stream) = field.retrieve(name,nameonly=True)
>   File "/home/www-data/web2py/gluon/dal.py", line 10029, in retrieve
>     if self.authorize and not self.authorize(row):
>   File "/home/www-data/web2py/applications/cryaboutit/models/db.py" 
> <https://62.75.246.181/admin/edit/cryaboutit/models/db.py>, line 138, in 
> <lambda>
>     db.personal_uploads.file_upload.authorize = lambda record: 
> auth.is_logged_in() and (record.members.contains(auth.user_id))
> AttributeError: 'list' object has no attribute 'contains'
>
>
>
> Thank you for any advice offered. 
>
>

-- 
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/d/optout.

Reply via email to