from zope.interface import implements
from twisted import plugin
from twisted.cred import checkers
from myapp.cred import SpecialChecker
class SpecialCheckerFactory(object):
"""
A checker factory for a specialized (fictional) API.
"""
# The class needs to implement both of these interfaces
# for the plugin system to find our factory.
implements(checkers.ICheckerFactory, plugin.IPlugin)
# This tells AuthOptionsMixin how to find this factory.
authType = "special"
# This is a one-line explanation of what arguments, if any,
# your particular cred plugin requires at the command-line.
argStringFormat = "A colon-separated key=value list."
# This help text can be multiple lines. It will be displayed
# when someone uses the "--help-auth-type special" command.
authHelp = """Some help text goes here ..."""
# This will be called once per command-line.
def generateChecker(self, argstring=""):
argdict = dict((x.split('=') for x in argstring.split(':')))
return SpecialChecker(**dict)
# We need to instantiate our class for the plugin to work.
theSpecialCheckerFactory = SpecialCheckerFactory()