~launchpad-pqm/launchpad/devel

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
56
57
58
59
60
61
62
# 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

__all__ = [
    'IWikiName',
    'IWikiNameSet',
    ]

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
from lp.services.fields import URIField


class IWikiName(IHasOwner):
    """Wiki for Users"""
    export_as_webservice_entry(publish_web_link=False)
    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"), schema=Interface, required=True, readonly=True))
    wiki = exported(
        URIField(title=_("Wiki host"),
                 allowed_schemes=['http', 'https'],
                 required=True))
    wikiname = exported(
        TextLine(title=_("Wikiname"), required=True))
    url = exported(
        TextLine(title=_("The URL for this wiki home page."), readonly=True))

    def destroySelf():
        """Remove this WikiName from the database."""


class IWikiNameSet(Interface):
    """The set of WikiNames."""

    def getByWikiAndName(wiki, wikiname):
        """Return the WikiName with the given wiki and wikiname.

        Return None if it doesn't exists.
        """

    def get(id):
        """Return the WikiName with the given id or None."""

    def new(person, wiki, wikiname):
        """Create a new WikiName pointing to the given Person."""