# 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


class DemoRealmFactory(object):
    """
    """
    implements(IPlugin, IRealmFactory)

    tag = "demo_realm"

    opt_help = dedent('''\
            A demonstration realm that creates an avatar from an ID with phony
            `email` and `domain` attributes.
            ''')

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

    def generateRealm(self, argstring=""):
        """
        """
        return DemoRealm() 

class DemoRealm(object):


    implements(IRealm)

    def requestAvatar(self, avatarId, mind, *interfaces):
        """
        """
        def cb():

# 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/demo_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



class DemoRealmFactory(object):
    """
    """
    implements(IPlugin, IRealmFactory)

    tag = "demo_realm"

    opt_help = dedent('''\
            A demonstration realm that creates an avatar from an ID with phony
            `email` and `domain` attributes.
            ''')

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

    def generateRealm(self, argstring=""):
        """
        """
        return DemoRealm() 

class DemoRealm(object):


    implements(IRealm)

    def requestAvatar(self, avatarId, mind, *interfaces):
        """
        """
        def cb():

            if not ICASUser in interfaces: