source: main/waeup.kofa/branches/uli-zc-async/src/waeup/kofa/userscontainer.txt @ 10021

Last change on this file since 10021 was 9211, checked in by uli, 12 years ago

Rollback r9209. Looks like multiple merges from trunk confuse svn when merging back into trunk.

File size: 1.3 KB
Line 
1User container for the Kofa
2***************************
3
4.. :doctest:
5.. :layer: waeup.kofa.testing.KofaUnitTestLayer
6
7Before we can start, we need some password managers available:
8
9    >>> from zope.app.authentication.placelesssetup import (
10    ...   PlacelessSetup)
11    >>> PlacelessSetup().setUp()
12
13We can create a user container which will hold the useraccounts for
14us:
15
16    >>> from waeup.kofa.userscontainer import UsersContainer
17    >>> myusers = UsersContainer()
18
19We can add users, just by passing a name, a password, and (optionally)
20a title and a description:
21
22    >>> myusers.addUser('bob', 'bobssecret')
23
24Now, Bob is in the container:
25
26    >>> list(myusers)
27    [u'bob']
28
29We can get Bob's account:
30
31    >>> bob = myusers['bob']
32    >>> bob
33    <waeup.kofa.authentication.Account object at 0x...>
34
35    >>> bob.name
36    'bob'
37
38    >>> bob.title
39    'bob'
40
41    >>> bob.description
42
43
44As we did not give a title, the name was taken instead
45for title (but not for description). The password, however, is stored encoded:
46
47    >>> bob.password
48    '{SSHA}...'
49
50We can delete users:
51
52    >>> myusers.delUser('alice')
53
54The container won't complain, although there is no ``alice`` stored
55yet. But we can really delete users:
56
57    >>> myusers.delUser('bob')
58    >>> list(myusers)
59    []
Note: See TracBrowser for help on using the repository browser.