Why are you trying to use Django HTTPResponse object with raw WSGI anyway? This 
would not normally be done. A Django HTTPResponse object isn't really designed 
for working direct with WSGI.

If you want WSGI type components for constructing WSGI applications piecemeal, 
you are better off using Werkzeug.

Most people though would use Django and Flask using their respective high level 
APIs and not try and take parts of them an use them with raw WSGI.

You are probably better off going and using Flask or Django and work through 
their tutorial, rather than trying to use random blog posts.

Graham

> On 10 Jul 2018, at 6:33 pm, at_your_mercy <[email protected]> wrote:
> 
> Sorry, I hate getting handfed... but can you point me to an example that 
> should work? This is all I have ever seen in the examples I've come across 
> and I've spent too many hours trying to get something to work. Also, I'm very 
> very unfamiliar with WSGI, is the application function the beginning of the 
> process or is the problem further back?
> 
> 
> On Tuesday, July 10, 2018 at 12:54:26 AM UTC-7, Graham Dumpleton wrote:
> Anyway, the obvious reason is that you are using:
> 
>     start_response('200 OK', [('Content-Type', 'text/html')])
>     return omicron.view.index(environ, start_response, request)
> 
> The cookie is sent back in response headers, but you aren't passing those 
> headers to start_response(), so they never get to the browser.
> 
> In other words you are only passing request body back.
> 
> Graham
> 
>> On 10 Jul 2018, at 5:51 pm, Graham Dumpleton <graham.d...@ <>gmail.com 
>> <http://gmail.com/>> wrote:
>> 
>> Okay, you aren't actually using Django request object so that is stupid 
>> request.
>> 
>>> On 10 Jul 2018, at 5:48 pm, Graham Dumpleton <graham.d...@ <>gmail.com 
>>> <http://gmail.com/>> wrote:
>>> 
>>> What if you look in 'request.COOKIES'?
>>> 
>>> Graham
>>> 
>>>> On 10 Jul 2018, at 5:39 pm, at_your_mercy <usera...@ <>gmail.com 
>>>> <http://gmail.com/>> wrote:
>>>> 
>>>> I suppose this could have gone in the Django group, but the problem starts 
>>>> in WSGI, so I'll try here first. I've followed numerous examples, but the 
>>>> only one that does not return errors are the implementations of the two 
>>>> functions below. There doesn't seem to be an HTTP_COOKIE key in the 
>>>> environ. The request value only gets set with POST and GET. Think 
>>>> something is wrong with my setup, because none of the common usage 
>>>> patterns I've seen online like request.POST don't work.
>>>> 
>>>> 
>>>> view.py
>>>> 
>>>> def index(environ, start_response, request):
>>>>     print request
>>>>     print environ.keys()
>>>>     template = loader.get_template('index-test.html')
>>>>     response = HttpResponse(template.render(None))
>>>>     response.set_cookie('name1', 'test-cookie')
>>>>     response.set_cookie('name2', 'test-cookie')
>>>>     return response
>>>> 
>>>> 
>>>> wsgi.py:
>>>> 
>>>> def application(environ, start_response):
>>>>     try:
>>>>         request_body_size = int(environ.get('CONTENT_LENGTH', 0))
>>>>     except (ValueError):
>>>>         request_body_size = 0
>>>>     request_body = environ['wsgi.input'].read(request_body_size)
>>>>     request = parse_qs(request_body)
>>>> 
>>>>     start_response('200 OK', [('Content-Type', 'text/html')])
>>>>     return omicron.view.index(environ, start_response, request)
>>>> 
>>>> OUTPUT:
>>>> 
>>>> request: {}
>>>> 
>>>> environ.keys():
>>>> ['RUN_MAIN', 'HTTP_REFERER', 'XDG_GREETER_DATA_DIR', 'QT4_IM_MODULE', 
>>>> 'SERVER_SOFTWARE', 'UPSTART_EVENTS', 'SCRIPT_NAME', 'XDG_SESSION_TYPE', 
>>>> 'REQUEST_METHOD', 'CONTENT_LENGTH', 'SERVER_PROTOCOL', 'HOME', 'DISPLAY', 
>>>> 'LANG', 'SHELL', 'PATH_INFO', 'XDG_DATA_DIRS', 
>>>> 'QT_LINUX_ACCESSIBILITY_ALWAYS_ON', 'MANDATORY_PATH', 
>>>> 'COMPIZ_CONFIG_PROFILE', 'UPSTART_INSTANCE', 'JOB', 'SESSION', 
>>>> 'LIBGL_ALWAYS_SOFTWARE', 'SERVER_PORT', 'CLUTTER_IM_MODULE', 'XMODIFIERS', 
>>>> 'GTK2_MODULES', 'HTTP_PRAGMA', 'XDG_RUNTIME_DIR', 'COMPIZ_BIN_PATH', 
>>>> 'VTE_VERSION', 'HTTP_CACHE_CONTROL', 'HTTP_CONNECTION', 'HTTP_HOST', 
>>>> 'wsgi.version', 'XDG_CURRENT_DESKTOP', 'XDG_SESSION_ID', 
>>>> 'DBUS_SESSION_BUS_ADDRESS', 'GNOME_KEYRING_PID', 'HTTP_ACCEPT', 
>>>> 'DESKTOP_SESSION', 'LESSCLOSE', 'DEFAULTS_PATH', 'wsgi.run_once', 
>>>> 'wsgi.errors', 'wsgi.multiprocess', 'HTTP_ACCEPT_LANGUAGE', 'INSTANCE', 
>>>> 'LS_COLORS', 'XDG_SEAT', 'GNOME_DESKTOP_SESSION_ID', 'LESSOPEN', 
>>>> 'QUERY_STRING', 'QT_IM_MODULE', 'LOGNAME', 'USER', 
>>>> 'GNOME_KEYRING_CONTROL', 'XDG_VTNR', 'PATH', 'TERM', 'HTTP_USER_AGENT', 
>>>> 'XDG_SESSION_PATH', 'XAUTHORITY', 'LANGUAGE', 'REMOTE_ADDR', 'SHLVL', 
>>>> 'QT_QPA_PLATFORMTHEME', 'wsgi.url_scheme', 'QT_ACCESSIBILITY', 'WINDOWID', 
>>>> 'SESSIONTYPE', 'IM_CONFIG_PHASE', 'GPG_AGENT_INFO', 'XDG_SESSION_DESKTOP', 
>>>> 'SSH_AUTH_SOCK', 'GDMSESSION', 'UPSTART_JOB', 'wsgi.multithread', 
>>>> 'XDG_SEAT_PATH', 'TZ', '_', 'wsgi.input', 'GTK_IM_MODULE', 
>>>> 'UPSTART_SESSION', 'XDG_CONFIG_DIRS', 'SERVER_NAME', 'GATEWAY_INTERFACE', 
>>>> 'OLDPWD', 'GDM_LANG', 'GTK_MODULES', 'PWD', 'DJANGO_SETTINGS_MODULE', 
>>>> 'CONTENT_TYPE', 'wsgi.file_wrapper', 'REMOTE_HOST', 'HTTP_ACCEPT_ENCODING']
>>>> 
>>>> You can see their is no HTTP_COOKIE in the keys.
>>>> 
>>>> -- 
>>>> You received this message because you are subscribed to the Google Groups 
>>>> "modwsgi" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>>> email to modwsgi+u...@ <>googlegroups.com <http://googlegroups.com/>.
>>>> To post to this group, send email to mod...@ <>googlegroups.com 
>>>> <http://googlegroups.com/>.
>>>> Visit this group at https://groups.google.com/group/modwsgi 
>>>> <https://groups.google.com/group/modwsgi>.
>>>> For more options, visit https://groups.google.com/d/optout 
>>>> <https://groups.google.com/d/optout>.
>>> 
>> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "modwsgi" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> To post to this group, send email to [email protected] 
> <mailto:[email protected]>.
> Visit this group at https://groups.google.com/group/modwsgi 
> <https://groups.google.com/group/modwsgi>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.

Reply via email to