Mercurial > p > roundup > code
view tools/fixroles.py @ 6806:bdd28b244839
- issue2551223 - fix timestamp truncation in mysql and postgresql
The data types used to represent timestamps in pg and mysql for
ephemeral tables: sessions and otks don't have enough signifcant
digits to work. As a result the timestamps are rounduped (up/down)
rsuling in the stored timestamp being 2 minutes (pg) or 2-3
hours(mysql) off from what it should be.
Modify db schema to use a numeric type that preserves more significant
figures. Implement schema upgrade. Document need for upgrade in
upgrading.txt.
Write tests for schema upgrade.
Implement test for updateTimestamp method on BasicDatabase that showed
this issue in the first place. Write overrides for test for
anydbm/memorydb which store timestamp properly or not at all.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Mon, 25 Jul 2022 17:20:20 -0400 |
| 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())
