# Path: txcas/constants.py
# VIEW_LOGIN = 0
# 
# VIEW_LOGIN_SUCCESS = 1
# 
# VIEW_LOGOUT = 2
# 
# VIEW_INVALID_SERVICE = 3
# 
# VIEW_ERROR_5XX = 4
# 
# VIEW_NOT_FOUND = 5
# 
# Path: txcas/exceptions.py
# class ViewNotImplementedError(CASError):
#     pass
# 
# Path: txcas/interface.py
# class IViewProvider(Interface):
# 
#     def provideView(view_type):
#         """
#         Provide a function that will render the named view.
#         Return None if the view is not provided.
#         """
# 
# class IViewProviderFactory(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 generateViewProvider(argstring=""):
#         """
#         Create an object that provides one or more views.
#         """
# 
# class IServiceManagerAcceptor(Interface):
#     
#     service_manager = Attribute('None or a reference to the current service manager plugin.')


import cgi
import itertools
import json
import sys
import urlparse
import txcas.settings
from textwrap import dedent
from txcas.constants import VIEW_LOGIN, VIEW_LOGIN_SUCCESS, VIEW_LOGOUT, \
                        VIEW_INVALID_SERVICE, VIEW_ERROR_5XX, VIEW_NOT_FOUND
from txcas.exceptions import ViewNotImplementedError
from txcas.interface import IViewProvider, IViewProviderFactory, \
                        IServiceManagerAcceptor
from jinja2 import Environment, FileSystemLoader
from jinja2.exceptions import TemplateNotFound
from twisted.internet import reactor, defer
from twisted.plugin import IPlugin
from twisted.python import log
from twisted.python.filepath import FilePath
from zope.interface import implements
                    Jinja2ViewProvider.__init__, config, ['self'])
        if len(missing) > 0:
            sys.stderr.write(
                "[ERROR][Jinja2ViewProvider] "
                "Missing the following settings: %s" % ', '.join(missing))
            sys.stderr.write('\n')
            sys.exit(1)

        txcas.utils.filter_args(Jinja2ViewProvider.__init__, config, ['self'])
        buf = ["[CONFIG][Jinja2ViewProvider] Settings:"]
        for k in sorted(config.keys()):
            v = config[k]
            buf.append(" - %s: %s" % (k, v))
        sys.stderr.write('\n'.join(buf))
        sys.stderr.write('\n')
        return Jinja2ViewProvider(**config)

class Jinja2ViewProvider(object):
    """
    A view provider based on Jinja2 templates.
    """
    implements(IViewProvider, IServiceManagerAcceptor)

    service_manager = None

    template_map = {
        VIEW_LOGIN: 'login.jinja2',
        VIEW_LOGIN_SUCCESS: 'login_success.jinja2',
        VIEW_LOGOUT: 'logout.jinja2',
        VIEW_INVALID_SERVICE: 'invalid_service.jinja2',

# Path: txcas/constants.py
# VIEW_LOGIN = 0
# 
# VIEW_LOGIN_SUCCESS = 1
# 
# VIEW_LOGOUT = 2
# 
# VIEW_INVALID_SERVICE = 3
# 
# VIEW_ERROR_5XX = 4
# 
# VIEW_NOT_FOUND = 5
# 
# Path: txcas/exceptions.py
# class ViewNotImplementedError(CASError):
#     pass
# 
# Path: txcas/interface.py
# class IViewProvider(Interface):
# 
#     def provideView(view_type):
#         """
#         Provide a function that will render the named view.
#         Return None if the view is not provided.
#         """
# 
# class IViewProviderFactory(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 generateViewProvider(argstring=""):
#         """
#         Create an object that provides one or more views.
#         """
# 
# class IServiceManagerAcceptor(Interface):
#     
#     service_manager = Attribute('None or a reference to the current service manager plugin.')


# Path: txcas/jinja_view_provider.py
import cgi
import itertools
import json
import sys
import urlparse
import txcas.settings
from textwrap import dedent
from txcas.constants import VIEW_LOGIN, VIEW_LOGIN_SUCCESS, VIEW_LOGOUT, \
                        VIEW_INVALID_SERVICE, VIEW_ERROR_5XX, VIEW_NOT_FOUND
from txcas.exceptions import ViewNotImplementedError
from txcas.interface import IViewProvider, IViewProviderFactory, \
                        IServiceManagerAcceptor
from jinja2 import Environment, FileSystemLoader
from jinja2.exceptions import TemplateNotFound
from twisted.internet import reactor, defer
from twisted.plugin import IPlugin
from twisted.python import log
from twisted.python.filepath import FilePath
from zope.interface import implements

                    Jinja2ViewProvider.__init__, config, ['self'])
        if len(missing) > 0:
            sys.stderr.write(
                "[ERROR][Jinja2ViewProvider] "
                "Missing the following settings: %s" % ', '.join(missing))
            sys.stderr.write('\n')
            sys.exit(1)

        txcas.utils.filter_args(Jinja2ViewProvider.__init__, config, ['self'])
        buf = ["[CONFIG][Jinja2ViewProvider] Settings:"]
        for k in sorted(config.keys()):
            v = config[k]
            buf.append(" - %s: %s" % (k, v))
        sys.stderr.write('\n'.join(buf))
        sys.stderr.write('\n')
        return Jinja2ViewProvider(**config)

class Jinja2ViewProvider(object):
    """
    A view provider based on Jinja2 templates.
    """
    implements(IViewProvider, IServiceManagerAcceptor)

    service_manager = None

    template_map = {
        VIEW_LOGIN: 'login.jinja2',
        VIEW_LOGIN_SUCCESS: 'login_success.jinja2',
        VIEW_LOGOUT: 'logout.jinja2',
        VIEW_INVALID_SERVICE: 'invalid_service.jinja2',

        VIEW_ERROR_5XX: 'error5xx.jinja2',