1# Copyright (C) 2017-2020 by the Free Software Foundation, Inc. 2# 3# This file is part of GNU Mailman. 4# 5# GNU Mailman is free software: you can redistribute it and/or modify it under 6# the terms of the GNU General Public License as published by the Free 7# Software Foundation, either version 3 of the License, or (at your option) 8# any later version. 9# 10# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT 11# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13# more details. 14# 15# You should have received a copy of the GNU General Public License along with 16# GNU Mailman. If not, see <https://www.gnu.org/licenses/>. 17 18"""Interfaces for plugins.""" 19 20from public import public 21from zope.interface import Attribute, Interface 22 23 24@public 25class IPlugin(Interface): 26 """A plugin providing components and hooks.""" 27 28 def pre_hook(): 29 """A plugin hook called in the first initialization step. 30 31 This is called before the database is initialized. 32 """ 33 34 def post_hook(): 35 """A plugin hook called in the second initialization step. 36 37 This is called after the database is initialized. 38 """ 39 40 resource = Attribute("""\ 41 The object for use as the root of this plugin's REST resources. 42 43 This is the resource which will be hooked up to the REST API, and 44 served at the /<api>/plugins/<plugin.name>/ location. All parsing 45 below that location is up to the plugin. 46 47 This attribute should be None if the plugin doesn't provide a REST 48 resource. 49 50 The resource must support getattr() and dir(). 51 """) 52