Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add more filetypes.

  • Loading branch information...
commit df86c7c6f7f860499e9d4421b184d9ff61c9049f 1 parent 9cdbc36
Chris McDonough authored
View
2  repoze/virginia/__init__.py
@@ -14,5 +14,5 @@ def make_app(global_config, root=None):
def get_root(environ):
return Directory(fs, root)
import repoze.virginia
- return make_app(get_root, repoze.virginia)
+ return make_app(get_root, repoze.virginia, default_redirects=False)
View
11 repoze/virginia/browser.py
@@ -2,6 +2,7 @@
import mimetypes
mimetypes.add_type('text/html', '.stx')
+mimetypes.add_type('application/pdf', '.pdf')
from zope.component import getMultiAdapter
from zope.structuredtext import stx2html
@@ -25,7 +26,7 @@ def __call__(self, *arg, **kw):
response = Response(result)
mt, encoding = mimetypes.guess_type(filename)
response.content_type = mt or 'text/plain'
- return Response(result)
+ return response
class DirectoryView(BrowserView):
defaults = ('index.html', 'index.stx')
@@ -38,9 +39,11 @@ def __call__(self, *arg, **kw):
pass
if index is None:
response = Response('No default view for %s' % self.context.path)
+ response.content_type = 'text/plain'
else:
fileview = FileView(index, self.request)
- return fileview()
+ response = fileview()
+ return response
class StructuredTextView(BrowserView):
""" Filesystem-based STX view
@@ -50,8 +53,8 @@ def __call__(self, *arg, **kw):
"""
return stx2html(self.context.source)
-class HTMLView(BrowserView):
- """ Filesystem-based HTML view
+class RawView(BrowserView):
+ """ Just return the source raw.
"""
def __call__(self, *arg, **kw):
""" Render html.
View
23 repoze/virginia/configure.zcml
@@ -30,9 +30,30 @@
<browser:page
for=".interfaces.IFile"
- class=".browser.HTMLView"
+ class=".browser.RawView"
name=".html"
permission="repoze.view"
/>
+ <browser:page
+ for=".interfaces.IFile"
+ class=".browser.RawView"
+ name=".pdf"
+ permission="repoze.view"
+ />
+
+ <browser:page
+ for=".interfaces.IFile"
+ class=".browser.RawView"
+ name=".txt"
+ permission="repoze.view"
+ />
+
+ <browser:page
+ for=".interfaces.IFile"
+ class=".browser.RawView"
+ name=".jpg"
+ permission="repoze.view"
+ />
+
</configure>
View
2  setup.cfg
@@ -1,3 +1,3 @@
[easy_install]
index_url = http://dist.repoze.org/bfg/dev/simple
-
+zip_ok = 0
Please sign in to comment.
Something went wrong with that request. Please try again.