Skip to content

Commit

Permalink
dont use a separate request factory; instead just assign ResponseClas…
Browse files Browse the repository at this point in the history
…s attr of the Request class to pyramid.response.Response
  • Loading branch information
mcdonc committed Nov 3, 2012
1 parent 41fab6a commit c60c0e0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
1 change: 1 addition & 0 deletions pyramid/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# package
9 changes: 2 additions & 7 deletions pyramid/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

from pyramid.interfaces import (
IRequest,
IRequestFactory,
IResponse,
ISessionFactory,
IResponseFactory,
Expand All @@ -29,12 +28,6 @@
from pyramid.url import URLMethodsMixin
from pyramid.util import InstancePropertyMixin


@implementer(IRequestFactory)
def default_request_factory(environ):
return Request(environ, ResponseClass=Response)


class TemplateContext(object):
pass

Expand Down Expand Up @@ -335,6 +328,8 @@ class Request(BaseRequest, DeprecatedRequestMethodsMixin, URLMethodsMixin,
matchdict = None
matched_route = None

ResponseClass = Response

@reify
def tmpl_context(self):
# docs-deprecated template context for Pylons-like apps; do not
Expand Down
5 changes: 2 additions & 3 deletions pyramid/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
)

from pyramid.httpexceptions import HTTPNotFound
from pyramid.request import default_request_factory
from pyramid.response import Response
from pyramid.request import Request
from pyramid.threadlocal import manager

from pyramid.traversal import (
Expand All @@ -49,7 +48,7 @@ def __init__(self, registry):
self.logger = q(IDebugLogger)
self.root_factory = q(IRootFactory, default=DefaultRootFactory)
self.routes_mapper = q(IRoutesMapper)
self.request_factory = q(IRequestFactory, default=default_request_factory)
self.request_factory = q(IRequestFactory, default=Request)
self.request_extensions = q(IRequestExtensions)
tweens = q(ITweens)
if tweens is None:
Expand Down
6 changes: 5 additions & 1 deletion pyramid/tests/test_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,17 @@ def test_class_conforms_to_IRequest(self):
from zope.interface.verify import verifyClass
from pyramid.interfaces import IRequest
verifyClass(IRequest, self._getTargetClass())
klass = self._getTargetClass()

def test_instance_conforms_to_IRequest(self):
from zope.interface.verify import verifyObject
from pyramid.interfaces import IRequest
verifyObject(IRequest, self._makeOne())

def test_ResponseClass_is_pyramid_Response(self):
from pyramid.response import Response
cls = self._getTargetClass()
self.assertEqual(cls.ResponseClass, Response)

def test_charset_defaults_to_utf8(self):
r = self._makeOne({'PATH_INFO':'/'})
self.assertEqual(r.charset, 'UTF-8')
Expand Down

0 comments on commit c60c0e0

Please sign in to comment.