
__exports__ = ["index", "other"]

from pages import index
from quixote.errors import TraversalError

def other(request):
    return "Handled by a Python function."

def fact(n):
    f = n*1L
    while n > 1:
        f *= n
        n -= 1
    return f

class IntegerUI:

    __exports__ = ["index", "factorial"]

    def __init__(self, request, component):
        try:
            self.n = int(component)
        except ValueError, exc:
            raise TraversalError(request.get_path(), str(exc))
    
    def factorial(self, request):
        return fact(self.n)
        
    def index(self, request):
        return "You have selected the integer %s" % self.n

def __getname__(request, component):
    return IntegerUI(request, component)
