I'm new to Pyramid, Pylons, etc., but have previously used other
Python web frameworks.
I'm trying to use view_config accept parameters for HTTP content-type
negotiation, e.g.
@view_config(route_name='service', request_method='GET',
accept='application/rdf+xml')
def service_rdf_xml(request):
:
@view_config(route_name='service', request_method='GET', accept='text/
turtle')
def service_turtle(request):
:
@view_config(route_name='service', request_method='GET', accept="text/
html")
def service_html(request):
:
if __name__ == '__main__':
# configuration settings
settings = {}
settings['reload_all'] = True
settings['debug_all'] = True
# configuration setup
config = Configurator(settings=settings)
config.add_route(name='service', pattern='/')
config.scan()
# serve app
app = config.make_wsgi_app()
server = make_server('0.0.0.0', 8080, app)
server.serve_forever()
...
I am assuming that this is what the accept parameter is provided for,
as I can't see any other useful purpose, but maybe that's a
misunderstanding on my part.
...
Using the above structure, I am running into a couple of issues:
(a) content-type matching is case sensitive. This if I send a request
with, say:
Accept: application/RDF+XML
it is not recognized by the URI dispatcher.
(b) I can't see any way to create a catch-all match, to be used when
none of the view_config options *with* accept parameters are matched.
I'm using "accept="text/html" for now, but that's not very
satisfactory for the reason above, and also...
(c) The matching doesn't honour the q= values generated by browsers;
e.g. I have Firefox generating:
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8,application/rdf+xml;q=0.93,text/rdf+n3;q=0.5
but I'm actually seeing the HTML version returned.
Is there something important I'm overlooking here?
Thanks.
#g
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.