I guess this is a problem due to out-of-order reference definitions.....
it's quite a leap to require web2py to know about auth_group when it's not
defined yet.......
Frankly, it should be treated as a bug (so, file an issue on google code)
only because of backwards compatibility
BTW,
auth_groups has a FK to auth_membership
auth_membership has a FK to auth_groups and a FK to auth_user
your model doesn't make any sense (and frankly, it's a waste of
functionality and doesn't improve any performance).... you're restricting a
user to be part of only one group, jumping from auth_user to auth_groups
without "passing" from auth_membership.
On Thursday, December 5, 2013 3:36:17 AM UTC+1, Jim S wrote:
>
> The following code is failing after update from 2.8.x to 2.8.2 (not
> positive what version I came from)
>
>
> auth.settings.hmac_key = 'sha512:9d8d83af-4769-410b-9cf5-e01a163b498d' #
> before define_tables()
>
> auth.settings.extra_fields['auth_user']= [
> Field('auth_group', 'reference auth_group', label='Group',
> requires=IS_EMPTY_OR(IS_IN_DB(db, 'auth_group.id',
> '%(group)s'))),
> Field('phone', 'string', length=20),
> Field('active', 'boolean', default=True),
> Field('image', 'upload'),
> Field('created', 'datetime', default=request.now, writable=False),
> Field('supplier', 'reference supplier', requires=IS_EMPTY_OR(
> IS_IN_DB(db, 'supplier.id'))),
> Field('distributor', 'reference distributor', requires=IS_EMPTY_OR
> (IS_IN_DB(db, 'distributor.id'))),
> Field('fax', 'string', length=20)
> ]
>
> ## create all tables needed by auth if not custom tables
> auth.define_tables(username=True, signature=False)
>
>
>
> The following traceback is generated:
>
> Traceback (most recent call last):
> File "C:\dev\web2py\gluon\restricted.py", line 217, in restricted
> exec ccode in environment
> File
> "C:/dev/web2py/applications/ibc/models/db.py"<http://127.0.0.1:8000/admin/default/edit/ibc/models/db.py>
> , line 69, in <module>
> auth.define_tables(username=True, signature=False)
> File "C:\dev\web2py\gluon\tools.py", line 1707, in define_tables
> format='%(username)s'))
> File "C:\dev\web2py\gluon\dal.py", line 8226, in define_table
> table = self.lazy_define_table(tablename,*fields,**args)
> File "C:\dev\web2py\gluon\dal.py", line 8263, in lazy_define_table
> polymodel=polymodel)
> File "C:\dev\web2py\gluon\dal.py", line 908, in create_table
> raise KeyError('Cannot resolve reference %s in %s definition' % (
> referenced, table._tablename))
> KeyError: 'Cannot resolve reference auth_group in auth_user definition'
>
>
>
>
>
--
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.