I am trying to follow the advice by Massimo and others on this thread but
am missing something.
Specifically, the follow code is intended to check if a user group exists,
and if not, create it. Unfortunately it executes every time until the
web2py server is restarted and the value is cached.
What do I need to change check/update the cache value correctly to see if a
user group exists?
My current code:
### Make sure the general user group exist, if not, create them.
if cache.ram('init_generalusers_group', lambda:db(db.auth_group.role ==
'general_users').count() == 0, None):
print "inside general users init fx"
db.auth_group.insert(role = 'general_users',
description = "A user group for all general
users.")
cache.ram.clear('init_generalusers_group')
GENUSER_GROUP_ID = cache.ram("init_generalusers_group",
lambda:db(db.auth_group.role == 'general_users').select().first().id, None)
Thanks in advance.
--
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/d/optout.