def test_simple_sub_resources(web_fixture):
"""During their construction, Widgets can add SubResources to their View. The SubResource
will then be available via a special URL underneath the URL of the Widget's View."""
fixture = web_fixture
@stubclass(SubResource)
class ASimpleSubResource(SubResource):
sub_regex = 'simple_resource'
sub_path_template = 'simple_resource'
@exempt
def handle_get(self, request):
return Response()
@stubclass(Widget)
class WidgetWithSubResource(Widget):
def __init__(self, view):
super(WidgetWithSubResource, self).__init__(view)
view.add_resource(ASimpleSubResource('uniquename'))
wsgi_app = fixture.new_wsgi_app(child_factory=WidgetWithSubResource.factory())
browser = Browser(wsgi_app)
browser.open('/_uniquename_simple_resource')
评论列表
文章目录