~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/registry/doc/gpgkey.txt

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2004-06-28 10:08:03 UTC
  • mfrom: (unknown (missing))
  • Revision ID: Arch-1:rocketfuel@canonical.com%soyuz--devel--0--patch-8
add ./sourcecode directory
Patches applied:

 * david.allouche@canonical.com--2004/soyuz--devel--0--base-0
   tag of rocketfuel@canonical.com/soyuz--devel--0--patch-7

 * david.allouche@canonical.com--2004/soyuz--devel--0--patch-1
   add ./sourcecode directory

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
= GPG Keys =
2
 
 
3
 
Launchpad models GPG keys in a GPGKey class.
4
 
 
5
 
    >>> from zope.component import getUtility
6
 
    >>> from lp.registry.interfaces.gpg import (
7
 
    ...     GPGKeyAlgorithm,
8
 
    ...     IGPGKeySet,
9
 
    ...     )
10
 
    >>> from lp.registry.interfaces.person import IPersonSet
11
 
    >>> personset = getUtility(IPersonSet)
12
 
    >>> foobar = personset.getByName('name16')
13
 
    >>> gpgkeyset = getUtility(IGPGKeySet)
14
 
    >>> keys = gpgkeyset.getGPGKeys(ownerid=foobar.id)
15
 
    >>> [key.keyid for key in keys]
16
 
    [u'12345678']
17
 
 
18
 
Adding new keys is pretty easy:
19
 
 
20
 
    >>> name12 = personset.getByName('name12')
21
 
    >>> gpgkeyset.new(name12.id, u'DEADBEEF',
22
 
    ...     'DEADBEEF12345678DEADBEEF12345678DEADBEEF', 1024, 
23
 
    ...     GPGKeyAlgorithm.LITTLE_G)
24
 
    <GPGKey...>
25
 
    >>> gpgkeyset.new(name12.id, u'DEADBEED',
26
 
    ...     'DEADBEED12345678DEADBEED12345678DEADBEED', 2048, GPGKeyAlgorithm.G)
27
 
    <GPGKey...>
28
 
 
29
 
As is pulling it based on the key ID:
30
 
 
31
 
    >>> key = gpgkeyset.getByFingerprint(
32
 
    ...     'DEADBEEF12345678DEADBEEF12345678DEADBEEF')
33
 
    >>> key.owner.name
34
 
    u'name12'
35
 
 
36
 
There's also a convenience method for fetching multiple GPG keys at
37
 
once:
38
 
 
39
 
    >>> keys = gpgkeyset.getGPGKeysForPeople([foobar, name12])
40
 
    >>> [(key.owner.name, key.keyid) for key in keys]
41
 
    [(u'name12', u'DEADBEED'),
42
 
     (u'name12', u'DEADBEEF'),
43
 
     (u'name16', u'12345678')]
44