~divmod-dev/divmod.org/1304710-storeless-adapter

« back to all changes in this revision

Viewing changes to Axiom/axiom/plugins/userbasecmd.py

  • Committer: glyph
  • Date: 2005-07-28 22:09:16 UTC
  • Revision ID: svn-v4:866e43f7-fbfc-0310-8f2a-ec88d1da2979:trunk:2
move this repository to a more official-looking URL

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
from zope.interface import classProvides
 
3
 
 
4
from twisted.python import usage
 
5
 
 
6
from twisted import plugin
 
7
 
 
8
from axiom import iaxiom, userbase
 
9
 
 
10
from xmantissa.website import WebSite
 
11
 
 
12
import getpass
 
13
 
 
14
class UserBaseCommand(usage.Options):
 
15
    classProvides(plugin.IPlugin, iaxiom.IAxiomaticCommand)
 
16
 
 
17
    name = 'userbase'
 
18
    description = 'Users.  Yay.'
 
19
 
 
20
    optParameters = [
 
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")]
 
24
 
 
25
    def postOptions(self):
 
26
        s = self.parent.getStore()
 
27
        s.transact(self.doConfiguration, s)
 
28
 
 
29
    def doConfiguration(self, s):
 
30
        for ls in s.query(userbase.LoginSystem):
 
31
            break
 
32
        else:
 
33
            ls = userbase.LoginSystem(store=s)
 
34
            ls.install()
 
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'],
 
42
                          self['domain'],
 
43
                          self['password'])
 
44
 
 
45