2
from zope.interface import classProvides
4
from twisted.python import usage
6
from twisted import plugin
8
from axiom import iaxiom, userbase
10
from xmantissa.website import WebSite
14
class UserBaseCommand(usage.Options):
15
classProvides(plugin.IPlugin, iaxiom.IAxiomaticCommand)
18
description = 'Users. Yay.'
21
('username', 'u', None, "The local-part of a user's ID"),
22
('domain', 'd', None, "The domain-part of a user's ID"),
23
('password', 'p', None, "The user's password")]
25
def postOptions(self):
26
s = self.parent.getStore()
27
s.transact(self.doConfiguration, s)
29
def doConfiguration(self, s):
30
for ls in s.query(userbase.LoginSystem):
33
ls = userbase.LoginSystem(store=s)
35
if self['username'] is not None:
36
if not self['domain']:
37
raise usage.UsageError(
38
"If you specify a username, you must specify their domain.")
39
if not self['password']:
40
self['password'] = getpass.getpass('Enter new AXIOM password: ' %())
41
ls.addAccount(self['username'],