# Path: txcas/casuser.py
# class User(object):
# 
#     implements(ICASUser)
# 
#     username = None
#     attribs = None
#     
#     def __init__(self, username, attribs):
#         self.username = username
#         self.attribs = attribs
#    
#     def logout(self):
#         pass
# 
# Path: txcas/interface.py
# class ICASUser(Interface):
# 
#     username = Attribute('String username')
#     attribs = Attribute('List of (attribute, value) tuples.')
# 
# class IRealmFactory(Interface):
# 
#     tag = Attribute('String used to identify the plugin factory.')
#     opt_help = Attribute('String description of the plugin.')
#     opt_usage = Attribute('String describes how to provide arguments for factory.')
# 
#     def generateRealm(argstring=""):
#         """
#         Create an object that implements IRealm.
#         """


from textwrap import dedent
from txcas.casuser import User
from txcas.interface import ICASUser, IRealmFactory
from twisted.cred.portal import IRealm
from twisted.internet import defer
from twisted.plugin import IPlugin
from zope.interface import implements

    tag = "basic_realm"

    opt_help = dedent('''\
            A basic realm that creates an avatar from an ID with no
            attributes.
            ''')

    opt_usage = '''This type of realm has no options.'''

    def generateRealm(self, argstring=""):
        """
        Produce a BaiscRealm instance.
        """
        return BasicRealm() 

class BasicRealm(object):
    """
    A Basic user realm that maps an avatar ID to an avatar with a matching
    username and no attributes.
    """

    implements(IRealm)

    def requestAvatar(self, avatarId, mind, *interfaces):
        """
        """
        def cb():
            if not ICASUser in interfaces:
                raise NotImplementedError("This realm only implements ICASUser.")

# Path: txcas/casuser.py
# class User(object):
# 
#     implements(ICASUser)
# 
#     username = None
#     attribs = None
#     
#     def __init__(self, username, attribs):
#         self.username = username
#         self.attribs = attribs
#    
#     def logout(self):
#         pass
# 
# Path: txcas/interface.py
# class ICASUser(Interface):
# 
#     username = Attribute('String username')
#     attribs = Attribute('List of (attribute, value) tuples.')
# 
# class IRealmFactory(Interface):
# 
#     tag = Attribute('String used to identify the plugin factory.')
#     opt_help = Attribute('String description of the plugin.')
#     opt_usage = Attribute('String describes how to provide arguments for factory.')
# 
#     def generateRealm(argstring=""):
#         """
#         Create an object that implements IRealm.
#         """


# Path: txcas/basic_realm.py
from textwrap import dedent
from txcas.casuser import User
from txcas.interface import ICASUser, IRealmFactory
from twisted.cred.portal import IRealm
from twisted.internet import defer
from twisted.plugin import IPlugin
from zope.interface import implements


    tag = "basic_realm"

    opt_help = dedent('''\
            A basic realm that creates an avatar from an ID with no
            attributes.
            ''')

    opt_usage = '''This type of realm has no options.'''

    def generateRealm(self, argstring=""):
        """
        Produce a BaiscRealm instance.
        """
        return BasicRealm() 

class BasicRealm(object):
    """
    A Basic user realm that maps an avatar ID to an avatar with a matching
    username and no attributes.
    """

    implements(IRealm)

    def requestAvatar(self, avatarId, mind, *interfaces):
        """
        """
        def cb():
            if not ICASUser in interfaces:
                raise NotImplementedError("This realm only implements ICASUser.")

            avatar = User(avatarId, None)