1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# Copyright 2009 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
# pylint: disable-msg=E0211,E0213
"""IRC interfaces."""
__metaclass__ = type
__all__ = [
'IIrcID',
'IIrcIDSet',
]
from lazr.restful.declarations import (
export_as_webservice_entry,
exported,
)
from lazr.restful.fields import Reference
from zope.interface import Interface
from zope.schema import (
Int,
TextLine,
)
from canonical.launchpad import _
from lp.registry.interfaces.role import IHasOwner
class IIrcID(IHasOwner):
"""A person's nickname on an IRC network."""
export_as_webservice_entry('irc_id')
id = Int(title=_("Database ID"), required=True, readonly=True)
# schema=Interface will be overriden in person.py because of circular
# dependencies.
person = exported(
Reference(
title=_("Owner"), required=True, schema=Interface, readonly=True))
network = exported(
TextLine(title=_("IRC network"), required=True))
nickname = exported(
TextLine(title=_("Nickname"), required=True))
def destroySelf():
"""Delete this `IIrcID` from the database."""
class IIrcIDSet(Interface):
"""The set of `IIrcID`s."""
def new(person, network, nickname):
"""Create a new `IIrcID` pointing to the given Person."""
def get(id):
"""Return the `IIrcID` with the given id or None."""
|