Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fix for 1.3

  • Loading branch information...
commit b2dee935e9773333e959dd868d58a2a49ffede0a 1 parent 6710690
Chris McDonough authored
4 CHANGES.txt
... ... @@ -1,14 +1,12 @@
1 1 Next release
2 2 ============
3 3
4   -- Update tests to run under BFG 1.1.
  4 +- Update tests to run under BFG 1.3.
5 5
6 6 - Added ``file_class`` attribute which lets subclasses of the
7 7 directory class define which file class to instantiate upon
8 8 traversal.
9 9
10   -- Forward compatibility with upcoming BFG release.
11   -
12 10 0.1
13 11 ===
14 12
3  content/index.stx
... ... @@ -0,0 +1,3 @@
  1 +Hello!
  2 +
  3 + This is some content.
9 repoze/virginia/__init__.py
@@ -4,12 +4,15 @@ def make_app(global_config, root=None):
4 4 if root is None:
5 5 raise ValueError('repoze.virginia requires a root')
6 6 import os
7   - from repoze.bfg.router import make_app
8 7 from repoze.virginia.models import Directory
9 8 from repoze.virginia.models import Filesystem
10 9 fs = Filesystem(os.path.abspath(os.path.normpath(root)))
11 10 def get_root(environ):
12 11 return Directory(fs, root)
13   - import repoze.virginia
14   - return make_app(get_root, repoze.virginia)
  12 + from repoze.bfg.configuration import Configurator
  13 + config = Configurator(root_factory=get_root)
  14 + config.begin()
  15 + config.load_zcml('repoze.virginia:configure.zcml')
  16 + config.end()
  17 + return config.make_wsgi_app()
15 18
10 repoze/virginia/tests/test_views.py
@@ -12,14 +12,14 @@ def _getFUT(self):
12 12 from repoze.virginia.views import file_view
13 13 return file_view
14 14
15   - def _registerView(self, app, name, *for_):
16   - testing.registerView(name, view=app, for_=for_)
  15 + def _registerView(self, app, name):
  16 + testing.registerView(name, view=app)
17 17
18 18 def test___call__(self):
19 19 response = DummyResponse()
20 20 view = make_view(response)
21 21 context = DummyFile('/foo/bar.ext')
22   - self._registerView(view, '.ext', None, None)
  22 + self._registerView(view, '.ext')
23 23 view = self._getFUT()
24 24 result = view(context, None)
25 25 self.assertEqual(result, response)
@@ -99,7 +99,7 @@ def test___call__(self):
99 99 ('Content-Length', '44')
100 100 )
101 101 self.assertEqual(headers[1],
102   - ('content-type', 'text/html; charset=UTF-8')
  102 + ('Content-Type', 'text/html; charset=UTF-8')
103 103 )
104 104
105 105 class RawViewTests(unittest.TestCase):
@@ -117,7 +117,7 @@ def test___call__(self):
117 117 ('Content-Length', '6')
118 118 )
119 119 self.assertEqual(headers[1],
120   - ('content-type', 'text/plain; charset=UTF-8')
  120 + ('Content-Type', 'text/plain; charset=UTF-8')
121 121 )
122 122
123 123 class DummyDirectory:
5 repoze/virginia/views.py
@@ -4,18 +4,17 @@
4 4 mimetypes.add_type('text/html', '.stx')
5 5 mimetypes.add_type('application/pdf', '.pdf')
6 6
7   -from zope.component import getMultiAdapter
8 7 from zope.structuredtext import stx2html
9 8
10 9 from webob import Response
11 10 from webob.exc import HTTPFound
12 11
13   -from repoze.bfg.interfaces import IView
  12 +from repoze.bfg.view import render_view_to_response
14 13
15 14 def file_view(context, request):
16 15 dirname, filename = os.path.split(context.path)
17 16 name, ext = os.path.splitext(filename)
18   - result = getMultiAdapter((context, request), IView, name=ext)
  17 + result = render_view_to_response(context, request, ext)
19 18 return result
20 19
21 20 def directory_view(context, request):
2  sample-virginia.ini
@@ -12,6 +12,6 @@ pipeline =
12 12 virginia
13 13
14 14 [server:main]
15   -use = egg:PasteScript#cherrypy
  15 +use = egg:Paste#http
16 16 host = 0.0.0.0
17 17 port = 6543
1  setup.cfg
... ... @@ -1,5 +1,4 @@
1 1 [easy_install]
2   -index_url = http://dist.repoze.org/bfgsite/simple
3 2 zip_ok = 0
4 3
5 4 [nosetests]

0 comments on commit b2dee93

Please sign in to comment.
Something went wrong with that request. Please try again.