Mercurial > p > roundup > code
view tools/fixroles.py @ 7698:4e37a7833708
doc: add FTS5 requirement for sqlite backend.
Document the requirement for FTS5 if you are using the sqlite backend.
Tonu Mikk reported issues with using a SQLite that was missing FTS5
support (RedHat 7 sqlite with python 3.6). Even though FTS5 has been
in the sqlite amalgamation since 2015-10-14 (v3.9.0) RedHat chose to
not build their package with that. This leads to a traceback when
initializing the database.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sat, 11 Nov 2023 19:39:57 -0500 |
| parents | 52c8324d1539 |
| children |
line wrap: on
line source
import sys from roundup import admin class AdminTool(admin.AdminTool): def __init__(self): self.commands = admin.CommandDict() for k in AdminTool.__dict__.keys(): if k[:3] == 'do_': self.commands[k[3:]] = getattr(self, k) self.help = {} for k in AdminTool.__dict__.keys(): if k[:5] == 'help_': self.help[k[5:]] = getattr(self, k) self.instance_home = '' self.db = None def do_fixroles(self, args): '''Usage: fixroles Set the roles property for all users to reasonable defaults. The admin user gets "Admin", the anonymous user gets "Anonymous" and all other users get "User". ''' # get the user class cl = self.get_class('user') for userid in cl.list(): username = cl.get(userid, 'username') if username == 'admin': roles = 'Admin' elif username == 'anonymous': roles = 'Anonymous' else: roles = 'User' cl.set(userid, roles=roles) return 0 if __name__ == '__main__': tool = AdminTool() sys.exit(tool.main())
