Problem with wsgiref.headers.Headers

Discussion in 'Python' started by Phil, Jan 15, 2010.

  1. Phil

    Phil Guest

    I am having an issue with wsgiref.headers.Headers.

    For example, if I do this...

    from wsgiref.headers import Headers
    list = []
    wrapper = Headers(list)
    wrapper['content-type'] = "text/html"
    print(list)
    print(wrapper)

    I get an empty list printed, and then the correct result for wrapper
    printed.

    Am I misunderstanding the documentation?

    class wsgiref.headers.Headers(headers)
    Create a mapping-like object wrapping headers, which must be a list of
    header name/value tuples as described in PEP 333. Any changes made to
    the new Headers object will directly update the headers list it was
    created with.

    Thanks for any help,

    Phil
    Phil, Jan 15, 2010
    #1
    1. Advertising

  2. Phil

    Phil Guest

    I left one crucial detail out. My concern was the fact that the
    original headers list being wrapped ('list' in my example) is not
    being updated.
    Phil, Jan 15, 2010
    #2
    1. Advertising

  3. En Fri, 15 Jan 2010 18:41:29 -0300, Phil <> escribió:

    > I am having an issue with wsgiref.headers.Headers.
    >
    > For example, if I do this...
    >
    > from wsgiref.headers import Headers
    > list = []
    > wrapper = Headers(list)
    > wrapper['content-type'] = "text/html"
    > print(list)
    > print(wrapper)
    >
    > I get an empty list printed, and then the correct result for wrapper
    > printed.


    You forgot to mention the Python version; the code works fine with 2.x,
    but fails in 3.1
    r68205 [1] is the culprit, in response to issue #4718 [2]
    The commit message says the changes were made to comply with
    http://www.wsgi.org/wsgi/Amendments_1.0 (basically, clarify
    str/unicode/bytes handling in Python 3.x). Either the documentation should
    be updated or the original behavior be maintained (meaning the original
    list contents could be altered); you probably should raise the question in
    the Web-SIG [3].

    [1] http://svn.python.org/view?view=rev&revision=68205
    [2] http://bugs.python.org/issue4718
    [3] http://www.python.org/community/sigs/current/web-sig/

    --
    Gabriel Genellina
    Gabriel Genellina, Jan 17, 2010
    #3
  4. En Fri, 15 Jan 2010 18:41:29 -0300, Phil <> escribió:

    > I am having an issue with wsgiref.headers.Headers.
    >
    > For example, if I do this...
    >
    > from wsgiref.headers import Headers
    > list = []
    > wrapper = Headers(list)
    > wrapper['content-type'] = "text/html"
    > print(list)
    > print(wrapper)
    >
    > I get an empty list printed, and then the correct result for wrapper
    > printed.


    You forgot to mention the Python version; the code works fine with 2.x,
    but fails in 3.1
    r68205 [1] is the culprit, in response to issue #4718 [2]
    The commit message says the changes were made to comply with
    http://www.wsgi.org/wsgi/Amendments_1.0 (basically, clarify
    str/unicode/bytes handling in Python 3.x). Either the documentation should
    be updated or the original behavior be maintained (meaning the original
    list contents could be altered); you probably should raise the question in
    the Web-SIG [3].

    [1] http://svn.python.org/view?view=rev&revision=68205
    [2] http://bugs.python.org/issue4718
    [3] http://www.python.org/community/sigs/current/web-sig/

    --
    Gabriel Genellina
    Gabriel Genellina, Jan 17, 2010
    #4
  5. En Fri, 15 Jan 2010 18:41:29 -0300, Phil <> escribió:

    > I am having an issue with wsgiref.headers.Headers.
    >
    > For example, if I do this...
    >
    > from wsgiref.headers import Headers
    > list = []
    > wrapper = Headers(list)
    > wrapper['content-type'] = "text/html"
    > print(list)
    > print(wrapper)
    >
    > I get an empty list printed, and then the correct result for wrapper
    > printed.


    You forgot to mention the Python version; the code works fine with 2.x,
    but fails in 3.1
    r68205 [1] is the culprit, in response to issue #4718 [2]
    The commit message says the changes were made to comply with
    http://www.wsgi.org/wsgi/Amendments_1.0 (basically, clarify
    str/unicode/bytes handling in Python 3.x). Either the documentation should
    be updated or the original behavior be maintained (meaning the original
    list contents could be altered); you probably should raise the question in
    the Web-SIG [3].

    [1] http://svn.python.org/view?view=rev&revision=68205
    [2] http://bugs.python.org/issue4718
    [3] http://www.python.org/community/sigs/current/web-sig/

    --
    Gabriel Genellina
    Gabriel Genellina, Jan 17, 2010
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shelly

    Custom HTTP headers problem

    Shelly, Nov 20, 2003, in forum: ASP .Net
    Replies:
    5
    Views:
    5,528
    John Saunders
    Nov 22, 2003
  2. dont bother
    Replies:
    0
    Views:
    766
    dont bother
    Mar 3, 2004
  3. Replies:
    2
    Views:
    335
  4. Ian
    Replies:
    2
    Views:
    1,907
  5. Gilles Lenfant

    Stopping a wsgiref server programmatically

    Gilles Lenfant, Jan 14, 2014, in forum: Python
    Replies:
    0
    Views:
    61
    Gilles Lenfant
    Jan 14, 2014
Loading...

Share This Page