Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

use scan instead of zcml

  • Loading branch information...
commit da9357ce0c7a58101fa693ba9b4c1f46d2769da9 1 parent 3b5174f
@mcdonc mcdonc authored
Showing with 17 additions and 4 deletions.
  1. +0 −1  setup.py
  2. +1 −2  virginia/__init__.py
  3. +16 −1 virginia/views.py
View
1  setup.py
@@ -23,7 +23,6 @@
requires = [
'pyramid>=1.0a10',
- 'pyramid_zcml',
'PasteScript',
'WebError',
'zope.structuredtext',
View
3  virginia/__init__.py
@@ -13,7 +13,6 @@ def main(global_config, **settings):
def get_root(environ):
return Directory(fs, root)
config = Configurator(root_factory=get_root, settings=settings)
- config.include('pyramid_zcml')
- config.load_zcml('virginia:configure.zcml')
+ config.scan()
return config.make_wsgi_app()
View
17 virginia/views.py
@@ -10,13 +10,21 @@
from webob.exc import HTTPFound
from pyramid.view import render_view_to_response
+from pyramid.view import view_config
+from virginia.interfaces import IFile
+from virginia.interfaces import IDirectory
+
+# default views: router will call these
+
+@view_config(context=IFile, permission='repoze.view')
def file_view(context, request):
dirname, filename = os.path.split(context.path)
name, ext = os.path.splitext(filename)
result = render_view_to_response(context, request, ext)
return result
+@view_config(context=IDirectory, permission='repoze.view')
def directory_view(context, request):
path_info = request.environ['PATH_INFO']
if not path_info.endswith('/'):
@@ -33,7 +41,10 @@ def directory_view(context, request):
response = Response('No default view for %s' % context.path)
response.content_type = 'text/plain'
return response
-
+
+# custom views: FileView will call these
+
+@view_config(context=IFile, permission='repoze.view', name='.stx')
def structured_text_view(context, request):
""" Filesystem-based STX view
"""
@@ -42,6 +53,10 @@ def structured_text_view(context, request):
response.content_type = 'text/html'
return response
+@view_config(context=IFile, permission='repoze.view', name='.html')
+@view_config(context=IFile, permission='repoze.view', name='.pdf')
+@view_config(context=IFile, permission='repoze.view', name='.txt')
+@view_config(context=IFile, permission='repoze.view', name='.jpg')
def raw_view(context, request):
""" Just return the source raw.
"""
Please sign in to comment.
Something went wrong with that request. Please try again.