How I can disable user_group, membership, permission, events?

29 views
Skip to first unread message

Вячеслав Анатольевич

unread,
Jun 15, 2017, 1:56:20 AM6/15/17
to web2py-users
So, I have db/table where i have data, i want just login user by the my field/data:

def user():
auth = Auth(db, signature=False)
auth.settings.create_user_groups = False
db.define_table('user_psw',
Field('tabnum', 'id', readable=False, writable=False),
Field('name', readable=False, writable=False),
Field('pwd', 'password', requires=CRYPT(), readable=False),
Field('ipadr'),
Field('groupid'),
Field('registration_key', writable=False, readable=False, default=''),
Field('reset_password_key', writable=False, readable=False, default=''),
Field('registration_id', writable=False, readable=False, default='')
)
if request.args(0) == 'login':
auth.settings.showid = False
auth.settings.table_user_name = 'user_psw'
auth.settings.login_userfield = 'name'
auth.settings.password_field = 'pwd'
auth.settings.login_next = URL('index.html')
auth.settings.logout_next = URL('index.html')
auth.settings.actions_disabled.append('register')
auth.settings.login_email_validate = False
custom_auth_table = db[auth.settings.table_user_name]
custom_auth_table.name.requires = IS_NOT_EMPTY()
custom_auth_table.pwd.requires = CRYPT()
auth.settings.table_user = custom_auth_table

login works, but some error:

File "D:\Web\server\web2py\gluon\tools.py", line 4159, in update_groups
table_membership.user_id == self.user.id).select()
File "D:\Web\server\web2py\gluon\packages\dal\pydal\objects.py", line 90, in __getattr__
raise AttributeError
AttributeError

Whats wrong? I write -
auth.settings.create_user_groups = False

How i can disable this? In project i dont need any groups, memebership, etc... only login

Anthony

unread,
Jun 15, 2017, 2:30:42 AM6/15/17
to web2py-users
web2py will still create the auth_group and auth_membership tables (they are not only used for the groups controlled by the auth.settings.create_user_groups setting, which only determines whether each user gets their own personal group). Anyway, I think the problem you are having is due to naming your user table's primary key column "tabnum" rather than "id" (the Auth code expects it to be called "id").

Also, you should not define Auth and its tables in the user() function, as the table definitions will be needed in other contexts, such as by decorators and appadmin. Move that to a model file.

Anthony

Вячеслав Анатольевич

unread,
Jun 15, 2017, 2:49:45 AM6/15/17
to web2py-users
Thx, i understand, that its all must be in model - im testing)
So, how i must write, that web2py understand "tabnum" like "id"?

In book i found:

db.mytable.other_id.represent = lambda id, row: row.myfield

and

primarykey=['accnum','acctype']

im trying, but still error.....
Reply all
Reply to author
Forward
0 new messages