Is this before you run auth.define_tables()? On Saturday, May 30, 2015 at 5:51:45 PM UTC-4, DeanK wrote: > > I'm trying to hide profile fields based on user role. For example > "basic_user" should have some fields hidden. So in my db.py where I'm > setting up a custom auth table: > > if 'profile' in request.args: > # If the user is a basic_user hide power_user stuff > if auth.has_membership('basic_user'): > custom_auth_table.custom_field1.readable = False > custom_auth_table.custom_field1.writable = False > > custom_auth_table.custom_field2.readable = False > custom_auth_table.custom_field2.writable = False > > > > When I try to view the profile I get this error: > > 1. > 2. > 3. > 4. > 5. > 6. > 7. > 8. > 9. > 10. > 11. > 12. > 13. > 14. > 15. > 16. > 17. > > Traceback (most recent call last): > File "/home/www-data/web2py/gluon/restricted.py", line 227, in restricted > exec ccode in environment > File "/home/www-data/web2py/applications/xxxx/models/db.py" > <https://52.1.146.129/admin/default/edit/flipoto/models/db.py>, line 191, in > <module> > if auth.has_membership('basic_user'): > File "/home/www-data/web2py/gluon/tools.py", line 3542, in has_membership > group_id = self.id_group(group_id) # interpret group_id as a role > File "/home/www-data/web2py/gluon/tools.py", line 3512, in id_group > rows = self.db(self.table_group().role == role).select() > File "/home/www-data/web2py/gluon/tools.py", line 1406, in table_group > return self.db[self.settings.table_group_name] > File "/home/www-data/web2py/gluon/packages/dal/pydal/base.py", line 900, in > __getitem__ > return self.__getattr__(str(key)) > File "/home/www-data/web2py/gluon/packages/dal/pydal/base.py", line 907, in > __getattr__ > return ogetattr(self, key) > AttributeError: 'DAL' object has no attribute 'auth_group' > > > > Is auth not setup yet at this point in the request or something like that? > Anyone have any thoughts? Thanks. >
-- 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.