Beispiel #1
0
def _q_lookup(request, name=''):
    if name == 'favicon.ico':
        return request.redirect('/images/favicon.ico')
    elif name == 'wdd_styles.css':
        return StaticFile(config.static_html_dir + '/wdd_styles.css',
                          mime_type='text/css',
                          cache_time=300)
    elif name == 'wdd_print.css':
        return StaticFile(config.static_html_dir + '/wdd_print.css',
                          mime_type='text/css',
                          cache_time=300)
    elif name.endswith('.js'):
        return StaticFile(config.static_html_dir + '/%s' % name,
                          mime_type='text/javascript',
                          cache_time=300)
    elif name == 'robots.txt':
        if config.enable_robots_txt:
            return robots()
        else:
            return not_found()
    elif name == 'browse':
        return Browse(request)
    elif name == 'timage':
        return TempImage()
    elif name == 'summary':
        return Summary(request)
    else:
        return not_found()
Beispiel #2
0
def _q_lookup (request, name=''):
    if name == 'ecohealth-2005-animals.pdf':
        return StaticFile(config.static_html_dir + '/ecohealth-2005-animals.pdf', 
            mime_type='application/pdf')
    elif name == 'ecohealth-2004-outfoxing.pdf':
        return StaticFile(config.static_html_dir + '/ecohealth-2004-outfoxing.pdf', 
            mime_type='application/pdf')
    else:
        return not_found()
Beispiel #3
0
 def orig__call__(self, request):
     contents = htmltext('')
     if self.mime_type == 'text/html':
         file_name = request.get_path()[1:]     # drop leading '/'
         contents += header(get_title_from_path(file_name))
         contents += htmltext(StaticFile.__call__(self, request))
         contents += footer()
     return contents
Beispiel #4
0
 def orig__call__(self, request):
     contents = htmltext('')
     if self.mime_type == 'text/html':
         file_name = request.get_path()[1:]  # drop leading '/'
         contents += header(get_title_from_path(file_name))
         contents += htmltext(StaticFile.__call__(self, request))
         contents += footer()
     return contents
Beispiel #5
0
 def __call__(self, req):
     # Add an ETag header for better caching.
     response = quixote.get_response()
     stat = os.stat(self.path)
     goo=str(stat.st_mtime)+self.path
     response.set_header('ETag', sha.sha(goo).digest().encode('hex'))
     
     return StaticFile.__call__(self)
Beispiel #6
0
 def _q_lookup(self, request, name):
     filename = self.path + os.path.sep + name
     if os.path.isdir(filename):
         return self.__class__(filename, self.xsldir)
     if os.path.isfile(filename):
         match = re.match(".*\.(.*)", name)
         if match is not None:
             if match.group(1) == 'xml':
                 return StaticFile(filename,
                                   mime_type="text/xml",
                                   encoding="UTF-8")
         return StaticFile(filename)
     else:
         match = re.match("(.*)\.(.*)", name)
         if match is not None:
             xmlfile = self.path + os.path.sep + match.group(1) + ".xml"
             if os.path.isfile(xmlfile):
                 return XmlFile(xmlfile, match.group(2), self.xsldir)
Beispiel #7
0
 def __call__(self, request):
     r = TemplateIO(html=0)
     file_name = request.get_path()[1:]     # drop leading '/'
     r += header(get_title_from_path(file_name))
     body = StaticFile.__call__(self, request)
     if isinstance(body, Stream):
         for hunk in body:
             r += hunk
     else:
         r += body
     r += footer()
     return r.getvalue()
Beispiel #8
0
 def __call__(self, request):
     r = TemplateIO(html=0)
     file_name = request.get_path()[1:]  # drop leading '/'
     r += header(get_title_from_path(file_name))
     body = StaticFile.__call__(self, request)
     if isinstance(body, Stream):
         for hunk in body:
             r += hunk
     else:
         r += body
     r += footer()
     return r.getvalue()
Beispiel #9
0
    def __init__(self, coord, push_list=[]):
        self.coord = coord            # PonyBuildCoordinator w/results etc.

        # get notified of new results by the coordinator...
        self.coord.add_listener(self)

        if push_list:
            print '** PuSH servers:', push_list
        else:
            print '** PuSH disabled'
        self.push_list = list(push_list)
        self.rss2 = RSS2FeedDirectory(coord)
        self.p = PackageDirectory(coord)
        self.img = StaticDirectory(os.path.join(templatesdir, 'img'))
        self.css = StaticFile(os.path.join(templatesdir, 'style.css'))
Beispiel #10
0
 def _q_index(self):
     # serve the index.html at /
     p = os.path.join(os.getcwd(), 'index.html')
     index = StaticFile(path=p, mime_type="text/html")
     return index()
Beispiel #11
0

def error(request):
    raise ValueError, "this is a Python exception"


def publish_error(request):
    raise PublishError(public_msg="Publishing error raised by publish_error")


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


def _q_resolve(component):
    # _q_resolve() is a hook that can be used to import only
    # when it's actually accessed.  This can be used to make
    # start-up of your application faster, because it doesn't have
    # to import every single module when it starts running.
    if component == 'form_demo':
        from quixote.demo.forms import form_demo
        return form_demo


# Get current directory
import os
from quixote.demo import forms
curdir = os.path.dirname(forms.__file__)
srcdir = StaticDirectory(curdir, list_directory=1)
q_ico = StaticFile(os.path.join(curdir, 'q.ico'))
Beispiel #12
0
def _q_lookup(request, component):
    if re.match('2\d\d\d', component):
        return XmlDir(chumproot + os.path.sep + component, xsldir)
    else:
        return StaticFile(chumproot + os.path.sep + component)