IRC Logs for #circuits Friday, 2018-12-14

*** prologic has joined #circuits04:54
*** patx has joined #circuits14:38
patxSo I got the wsgiapp.py example working on PythonAnywhere, turns out all the issues I was having were from using Python3.7, when I switched to 2.7 it worked fine.14:40
patxNow however when I try to return a self.redirect("/index") to return to the index page I am getting an error that I'm not really sure why, something with http headers needing to be str (error message: https://paste.ofcode.org/xkqwxq5g6UNZxsdAyNwgUJ)14:44
patxAny ideas as to why self.redirect would be having issues when run using wsgi (application = Application() + Root())?14:45
spaceonedoes it work if you change:14:48
spaceonestart_response(str(status), headers, exc_info)14:48
spaceoneinto:14:48
spaceonestart_response(str(status), '\r\n'.join(headers) + '\r\n', exc_info)14:48
spaceone?14:48
patx@spaceone i should change that in the "site-packages/circuits/web/wsgi.py" file?14:49
kdbUnknown Command: spaceone14:49
spaceoneoh wait:14:49
spaceoneyes14:49
patxok14:49
spaceonestart_response(str(status), str(headers), exc_info)14:49
spaceone→ but take this!14:49
patxok thanks alot ill let you know14:49
spaceone:)14:50
patxhmmm now its saying headers must be a list, https://paste.ofcode.org/zNLvzuziZxYSxgRtZjvs3614:53
patxshould i change str() to list()?14:54
spaceoneokay14:54
spaceoneno14:54
spaceonechange it to:14:54
spaceonelist(headers.items())14:54
spaceonehttps://www.python.org/dev/peps/pep-0333/#the-start-response-callable → here is the API description14:55
patxcool14:55
patxthanks let see14:55
patxi would think it would already be in a list because of "headers = list(self.response.headers.items())"14:57
patxbut guess not14:57
patx:/14:58
patxTypeError: http header must be defined in a tuple 214:58
spaceoneoh yes, hm14:58
spaceonethat is very awkward14:58
patxright14:58
patxdisregard the 2 at the end there14:58
spaceonecan you make a print repr(headers) before the function call?15:00
spaceonecan you make a print(repr(headers)) before the function call?15:00
spaceoneif you tell me how i can setup such an environment i can have a closer look15:02
patxits on pythonanywhere.com15:04
patxwhere would that print out the app is running from a wsgi file in /var/www15:05
spaceoneraise ValueError(repr(headers))15:07
spaceone→ this is better if you don't have access to stdout15:07
patxyeah would i put that before my function returning the redirect or would i put it before __call__15:08
patxkinda of a newb here sorry for all the questions15:09
spaceoneno problem15:11
spaceonei will register at pythonanywhere15:11
spaceonei hope i can do this with the free account15:11
patxyes15:12
patxim on the free account lol15:12
spaceonegood15:13
spaceonecan you give me the files i need to upload?15:13
spaceonei just did a git clone circuits there15:13
patxok i installed circuits using pip just so you know idk if that will make a difference15:14
spaceoneok15:15
spaceoneand you used python 3.7?15:15
patx2.715:15
patxtried 3.7 but it doesnt work15:15
patxthis code: https://paste.ofcode.org/Uvtf5pVz82acSjGbaaF9Ds    is running in the wsgi file named after your username in /var/www15:16
patxmine is called patx_pythonanywhere_com_wsgi.py15:16
patxif i change self.redirect to return a str the script works fine15:16
patxmy forum with an admin from pythonanywhere on getting the example app (examples/web/wsgiapp.py) to work properly, only thing i did that worked was use 2.715:22
patxhttps://www.pythonanywhere.com/forums/topic/13642/15:22
spaceonehm, i get a blank white page15:23
patxyes on /15:24
patxbut if you got to /add/test15:24
patxit errors from the redirect15:24
spaceoneah okay15:25
patxif i change the redirect to return 'success' it displays "success" and then if i navigate to / it will display whatever (the str arg entered on /add/whatever)15:25
spaceonehmm, i get a content-length mismatch15:26
spaceonebut not the traceback you received15:26
patxwhen trying to access /add/arg ?15:26
patxor on /index?15:27
spaceonenow both15:27
patxhmm15:27
spaceonehttp://spaceone.pythonanywhere.com/15:27
patxhttp://patx.pythonanywhere.com/15:28
patxhttps://paste.ofcode.org/39b9kHeyDWKAdqMQgQUx7ym15:29
patxthats code running on my app right now15:29
patxyou can see its displaying the items of the list on /index15:29
patxand if you go to /add/whatever15:29
patxit would add "whatever" to the list and display a page saying success15:29
patxthen if i go to /index it will display the new added whatever15:30
patxbut when i add the redirect (changing line 20 of the most recently pasted code to self.redirect("/")) it breaks the app15:31
patxand idk why the redirect is breaking it15:31
spaceoneokay, i now have: TypeError: http header value must be a string15:32
spaceonebut this is with python 2.715:32
patxyes15:32
patxi am using 2.7 as well15:33
patx3+ versions do not deploy15:33
patxyou get the content length mismatch error15:33
patxso you HAVE to use 2.7 it appears15:34
spaceoneah okay15:35
spaceoneso py3.7 is completely broken and py2.7 only half broken?15:35
patxlmao15:36
patxyep15:36
patxfrustrating15:36
spaceoneokay, fixed it: http://spaceone.pythonanywhere.com/15:38
spaceoneokay, fixed it: http://spaceone.pythonanywhere.com/add/bla15:38
patxnice!!15:42
patxwhatd you do?15:42
spaceonei will debug this further, one moment15:42
spaceonewill create a patch then15:42
patxok nice thanks alot your killing it!15:43
spaceonethe error is in circuits.web.errors.redirect()15:51
spaceonethere it creates a unicode() object of the location instead of a str()15:52
spaceoneand the Headers class is also dump as it doesn't convert it15:52
spaceoneand allows such invalid input15:52
patxhmm ok15:55
patxurl = request.uri.relative(url).unicode()15:56
patxthat?15:56
spaceoneyes15:56
spaceonepatx: https://bpaste.net/show/a29b293c0b2015:56
spaceone→ you can use that as a patch meanwhile15:56
spaceonewith httoop / circuits.http this would not have happend :D15:56
patxcool thanks15:57
patxshould i be using circuits.http or?15:57
spaceonewell, i don't think so16:00
spaceonei didn't write the WSGI part for it yet16:01
patxlol ok16:01
patxgot it16:01
spaceoneso currently you can only run it as a standalone application16:01
spaceone(which is required for all my websites :D)16:01
patxmakes sense ;)16:02
spaceonecircuits.http forces you also to use correct HTTP behavior, e.g. use the HTTP methods, etc16:02
spaceoneyou could have a look at my websites, they are open source16:02
spaceoneif you like the coding structure i can write the WSGI thing for it16:02
spaceonehttps://github.com spaceone websites (add the slashes, i don't want the url to be crawled)16:03
patxgotcha thanks ill take a look16:05
patxspaceone, the headers.py file was the only thing that needed changing correct?16:11
patxor did you touch errors and wsgi as well?16:11
spaceonepatx: it's the only file, yes16:11
patxok16:12
patxweirdly, i am still getting an error16:12
spaceonewhic?16:13
spaceonewhich?16:13
spaceonedid you click the restart button?16:13
patxyeah the reload one right?16:14
spaceoneyes16:14
patxyes16:14
patxhang on16:14
patxnevermind16:14
patxi did hit it before i swear lmao must not have reloaded16:15
patxworking great, thanks alot man16:15
spaceoneno problem16:15
spaceonei will try to see how i can fix python316:15
spaceonebut well, in the past i sweared not to losse time in circuits web anymore :D16:16
patxthatd be really cool, i couldnt even get just the basic wsgiapp.py to work, kept getting content length errors16:16
patxlol yeah i can see you like working with the HTTP methods directly looking at your code for your websites16:16
spaceoneprobably also an encoding issue16:17
patxwell if you get around to it16:17
patxill also take a look see if i see anything because id prefer to use py316:17
patxcheers! ill be back later16:18
spaceonecu16:18
*** patx has quit IRC16:45

Generated by irclog2html.py 2.14.0 by Marius Gedminas - find it at mg.pov.lt!