Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 12 commits
  • 6 files changed
  • 0 comments
  • 5 contributors
6 docs/glossary.rst
Source Rendered
@@ -922,9 +922,9 @@ Glossary
922 922 http://docs.pylonsproject.org/projects/pyramid_debugtoolbar/dev/ .
923 923
924 924 scaffold
925   - A project template that helps users get started writing a Pyramid
926   - application quickly. Scaffolds are usually used via the ``pcreate``
927   - command.
  925 + A project template that generates some of the major parts of a Pyramid
  926 + application and helps users to quickly get started writing larger
  927 + applications. Scaffolds are usually used via the ``pcreate`` command.
928 928
929 929 pyramid_exclog
930 930 A package which logs Pyramid application exception (error) information
4 docs/narr/commandline.rst
Source Rendered
@@ -460,7 +460,7 @@ to the console.
460 460
461 461 You can add request header values by using the ``--header`` option::
462 462
463   - $ bin/prequest --header=Host=example.com development.ini /
  463 + $ bin/prequest --header=Host:example.com development.ini /
464 464
465 465 Headers are added to the WSGI environment by converting them to their
466 466 CGI/WSGI equivalents (e.g. ``Host=example.com`` will insert the ``HTTP_HOST``
@@ -718,7 +718,7 @@ we'll pretend you have a distribution with a package in it named
718 718 def settings_show():
719 719 description = """\
720 720 Print the deployment settings for a Pyramid application. Example:
721   - 'psettings deployment.ini'
  721 + 'show_settings deployment.ini'
722 722 """
723 723 usage = "usage: %prog config_uri"
724 724 parser = optparse.OptionParser(
7 docs/tutorials/wiki/installation.rst
Source Rendered
@@ -130,9 +130,10 @@ Preparation, Windows
130 130 Make a Project
131 131 ==============
132 132
133   -Your next step is to create a project. :app:`Pyramid` supplies a variety of
134   -scaffolds to generate sample projects. For this tutorial, we will use the
135   -:term:`ZODB` -oriented scaffold named ``zodb``.
  133 +Your next step is to create a project. For this tutorial, we will use the
  134 +:term:`scaffold` named ``zodb``, which generates an application
  135 +that uses :term:`ZODB` and :term:`traversal`. :app:`Pyramid`
  136 +supplies a variety of scaffolds to generate sample projects.
136 137
137 138 The below instructions assume your current working directory is the
138 139 "virtualenv" named "pyramidtut".
8 docs/tutorials/wiki2/installation.rst
Source Rendered
@@ -67,10 +67,10 @@ Preparation, Windows
67 67 Making a Project
68 68 ================
69 69
70   -Your next step is to create a project. :app:`Pyramid` supplies a
71   -variety of scaffolds to generate sample projects. We will use the
72   -``alchemy`` scaffold, which generates an application
73   -that uses :term:`SQLAlchemy` and :term:`URL dispatch`.
  70 +Your next step is to create a project. For this tutorial, we will use the
  71 +:term:`scaffold` named ``alchemy``, which generates an application
  72 +that uses :term:`SQLAlchemy` and :term:`URL dispatch`. :app:`Pyramid`
  73 +supplies a variety of scaffolds to generate sample projects.
74 74
75 75 The below instructions assume your current working directory is the
76 76 "virtualenv" named "pyramidtut".
6 pyramid/static.py
@@ -108,7 +108,7 @@ def __call__(self, context, request):
108 108 resource_path ='%s/%s' % (self.docroot.rstrip('/'), path)
109 109 if resource_isdir(self.package_name, resource_path):
110 110 if not request.path_url.endswith('/'):
111   - self.add_slash_redirect(request)
  111 + return self.add_slash_redirect(request)
112 112 resource_path = '%s/%s' % (resource_path.rstrip('/'),self.index)
113 113 if not resource_exists(self.package_name, resource_path):
114 114 raise HTTPNotFound(request.url)
@@ -120,7 +120,7 @@ def __call__(self, context, request):
120 120 filepath = normcase(normpath(join(self.norm_docroot, path)))
121 121 if isdir(filepath):
122 122 if not request.path_url.endswith('/'):
123   - self.add_slash_redirect(request)
  123 + return self.add_slash_redirect(request)
124 124 filepath = join(filepath, self.index)
125 125 if not exists(filepath):
126 126 raise HTTPNotFound(request.url)
@@ -132,7 +132,7 @@ def add_slash_redirect(self, request):
132 132 qs = request.query_string
133 133 if qs:
134 134 url = url + '?' + qs
135   - raise HTTPMovedPermanently(url)
  135 + return HTTPMovedPermanently(url)
136 136
137 137 _seps = set(['/', os.sep])
138 138 def _contains_slash(item):
109 pyramid/tests/test_static.py
@@ -70,16 +70,26 @@ def test_oob_dotdotslash(self):
70 70 inst = self._makeOne('pyramid.tests:fixtures/static')
71 71 request = self._makeRequest({'PATH_INFO':'/subdir/../../minimal.pt'})
72 72 context = DummyContext()
73   - response = inst(context, request)
74   - self.assertEqual(response.status, '404 Not Found')
  73 + from pyramid.httpexceptions import HTTPNotFound
  74 + try:
  75 + response = inst(context, request)
  76 + except HTTPNotFound as e:
  77 + self.assertEqual(e.code, 404)
  78 + else:
  79 + self.assertEqual(response.status, '404 Not Found')
75 80
76 81 def test_oob_dotdotslash_encoded(self):
77 82 inst = self._makeOne('pyramid.tests:fixtures/static')
78 83 request = self._makeRequest(
79 84 {'PATH_INFO':'/subdir/%2E%2E%2F%2E%2E/minimal.pt'})
80 85 context = DummyContext()
81   - response = inst(context, request)
82   - self.assertEqual(response.status, '404 Not Found')
  86 + from pyramid.httpexceptions import HTTPNotFound
  87 + try:
  88 + response = inst(context, request)
  89 + except HTTPNotFound as e:
  90 + self.assertEqual(e.code, 404)
  91 + else:
  92 + self.assertEqual(response.status, '404 Not Found')
83 93
84 94 def test_oob_os_sep(self):
85 95 import os
@@ -88,15 +98,25 @@ def test_oob_os_sep(self):
88 98 request = self._makeRequest({'PATH_INFO':'/subdir/%s%sminimal.pt' %
89 99 (dds, dds)})
90 100 context = DummyContext()
91   - response = inst(context, request)
92   - self.assertEqual(response.status, '404 Not Found')
  101 + from pyramid.httpexceptions import HTTPNotFound
  102 + try:
  103 + response = inst(context, request)
  104 + except HTTPNotFound as e:
  105 + self.assertEqual(e.code, 404)
  106 + else:
  107 + self.assertEqual(response.status, '404 Not Found')
93 108
94 109 def test_resource_doesnt_exist(self):
95 110 inst = self._makeOne('pyramid.tests:fixtures/static')
96 111 request = self._makeRequest({'PATH_INFO':'/notthere'})
97 112 context = DummyContext()
98   - response = inst(context, request)
99   - self.assertEqual(response.status, '404 Not Found')
  113 + from pyramid.httpexceptions import HTTPNotFound
  114 + try:
  115 + response = inst(context, request)
  116 + except HTTPNotFound as e:
  117 + self.assertEqual(e.code, 404)
  118 + else:
  119 + self.assertEqual(response.status, '404 Not Found')
100 120
101 121 def test_resource_isdir(self):
102 122 inst = self._makeOne('pyramid.tests:fixtures/static')
@@ -174,8 +194,13 @@ def test_not_found(self):
174 194 inst = self._makeOne('pyramid.tests:fixtures/static')
175 195 request = self._makeRequest({'PATH_INFO':'/notthere.html'})
176 196 context = DummyContext()
177   - response = inst(context, request)
178   - self.assertEqual(response.status, '404 Not Found')
  197 + from pyramid.httpexceptions import HTTPNotFound
  198 + try:
  199 + response = inst(context, request)
  200 + except HTTPNotFound as e:
  201 + self.assertEqual(e.code, 404)
  202 + else:
  203 + self.assertEqual(response.status, '404 Not Found')
179 204
180 205 def test_resource_with_content_encoding(self):
181 206 inst = self._makeOne('pyramid.tests:fixtures/static')
@@ -251,33 +276,52 @@ def test_oob_singledot(self):
251 276 request = self._makeRequest()
252 277 request.subpath = ('.', 'index.html')
253 278 context = DummyContext()
254   - response = inst(context, request)
255   - self.assertEqual(response.status, '404 Not Found')
  279 + from pyramid.httpexceptions import HTTPNotFound
  280 + try:
  281 + response = inst(context, request)
  282 + except HTTPNotFound as e:
  283 + self.assertEqual(e.code, 404)
  284 + else:
  285 + self.assertEqual(response.status, '404 Not Found')
256 286
257 287 def test_oob_emptyelement(self):
258 288 inst = self._makeOne('pyramid.tests:fixtures/static')
259 289 request = self._makeRequest()
260 290 request.subpath = ('', 'index.html')
261 291 context = DummyContext()
262   - response = inst(context, request)
263   - self.assertEqual(response.status, '404 Not Found')
  292 + from pyramid.httpexceptions import HTTPNotFound
  293 + try:
  294 + response = inst(context, request)
  295 + except HTTPNotFound as e:
  296 + self.assertEqual(e.code, 404)
  297 + else:
  298 + self.assertEqual(response.status, '404 Not Found')
264 299
265 300 def test_oob_dotdotslash(self):
266 301 inst = self._makeOne('pyramid.tests:fixtures/static')
267 302 request = self._makeRequest()
268 303 request.subpath = ('subdir', '..', '..', 'minimal.pt')
269 304 context = DummyContext()
270   - response = inst(context, request)
271   - self.assertEqual(response.status, '404 Not Found')
  305 + from pyramid.httpexceptions import HTTPNotFound
  306 + try:
  307 + response = inst(context, request)
  308 + except HTTPNotFound as e:
  309 + self.assertEqual(e.code, 404)
  310 + else:
  311 + self.assertEqual(response.status, '404 Not Found')
272 312
273 313 def test_oob_dotdotslash_encoded(self):
274 314 inst = self._makeOne('pyramid.tests:fixtures/static')
275 315 request = self._makeRequest()
276 316 request.subpath = ('subdir', '%2E%2E', '%2E%2E', 'minimal.pt')
277 317 context = DummyContext()
278   - response = inst(context, request)
279   - self.assertEqual(response.status, '404 Not Found')
280   -
  318 + from pyramid.httpexceptions import HTTPNotFound
  319 + try:
  320 + response = inst(context, request)
  321 + except HTTPNotFound as e:
  322 + self.assertEqual(e.code, 404)
  323 + else:
  324 + self.assertEqual(response.status, '404 Not Found')
281 325 def test_oob_os_sep(self):
282 326 import os
283 327 inst = self._makeOne('pyramid.tests:fixtures/static')
@@ -285,16 +329,26 @@ def test_oob_os_sep(self):
285 329 request = self._makeRequest()
286 330 request.subpath = ('subdir', dds, dds, 'minimal.pt')
287 331 context = DummyContext()
288   - response = inst(context, request)
289   - self.assertEqual(response.status, '404 Not Found')
  332 + from pyramid.httpexceptions import HTTPNotFound
  333 + try:
  334 + response = inst(context, request)
  335 + except HTTPNotFound as e:
  336 + self.assertEqual(e.code, 404)
  337 + else:
  338 + self.assertEqual(response.status, '404 Not Found')
290 339
291 340 def test_resource_doesnt_exist(self):
292 341 inst = self._makeOne('pyramid.tests:fixtures/static')
293 342 request = self._makeRequest()
294 343 request.subpath = ('notthere,')
295 344 context = DummyContext()
296   - response = inst(context, request)
297   - self.assertEqual(response.status, '404 Not Found')
  345 + from pyramid.httpexceptions import HTTPNotFound
  346 + try:
  347 + response = inst(context, request)
  348 + except HTTPNotFound as e:
  349 + self.assertEqual(e.code, 404)
  350 + else:
  351 + self.assertEqual(response.status, '404 Not Found')
298 352
299 353 def test_resource_isdir(self):
300 354 inst = self._makeOne('pyramid.tests:fixtures/static')
@@ -361,8 +415,13 @@ def test_not_found(self):
361 415 request = self._makeRequest()
362 416 request.subpath = ('notthere.html',)
363 417 context = DummyContext()
364   - response = inst(context, request)
365   - self.assertEqual(response.status, '404 Not Found')
  418 + from pyramid.httpexceptions import HTTPNotFound
  419 + try:
  420 + response = inst(context, request)
  421 + except HTTPNotFound as e:
  422 + self.assertEqual(e.code, 404)
  423 + else:
  424 + self.assertEqual(response.status, '404 Not Found')
366 425
367 426 class DummyContext:
368 427 pass

No commit comments for this range

Something went wrong with that request. Please try again.