23 Feb 2017
I thought I'd break up the holy trinity of Flask to make it easier to learn: Flask, Jinja2, and Werkzeug. As it turns out, separating Flask from Jinja2 might be impossible. I don't know for sure yet. Anyway, I used Shalabh Aggarwal's tutorial, which is thankfully focused on templating, which means a bit more Jinja2 than usual.
I am still trying to get the hang of Flask spreading code over many files, and involving code from Flask, Jinja2, HTML, and even JS and CSS. But I feel like maybe I am progressing, even if just a tiny bit. It's hard to tell since progress is incremental. I'll know soon, I hope.
I couldn't do part 3 of Aggarwal's tutorial. Something is wrong somewhere and I have no clue what it is. In part 2, I couldn't import render_field from _help.html as _help.jinja. So I googled it and found a solution, which was to import the whole _help.html and call render_field normally, like form.render_field(). I have no idea why Aggarwal's method didn't work for me.
25 Feb 2017
So, after slightly more than a full week floundering, I might have found a good tutorial. I don't know whom he is, but this CS350 chap seems pretty ok so far, although admittedly, we haven't reached any of the difficult stuff yet.
In spite of that, I do like that he introduced me to Cloud9 and Gitlab. Cloud9, especially, might solve some issues for me. For instance, the Werkzeug site uses Redis for its tutorials, and it doesn't quite run on Windows, and I couldn't figure out how to use the version ported to Windows to work alongside the code the Werkzeug tutorial provided. Cloud9 allows me to run Linux, amongst other things, which means I can use Redis if I want to. CS350 doesn't use Redis though.
I know I could have used VirtualBox, but I find it a bit of a pain to use, for reasons I no longer remember. Haven't used it in a while.
And yes, after I tried out Aggarwal's Jinja2 templating tutorial, I decided to try a Werkzeug one, using the official site's tutorial. It was horrible. I gave up midway because I couldn't figure out the Redis bit.
26 Feb 2017, Part A
Following CS350 into PostgreSQL on Cloud9. It's unfamiliar, because I don't see the SQL database file anywhere in Cloud9. The method of interface makes it a bit hard to grok. The data is rendered in text on the command line. Is that ASCII? I don't know. Anyway, I do understand it a little because a month or so ago I did Charles Severance's excellent Using Databases with Python. It uses SQLite. So, I kind of get some of the commands. I wish I could continue with SQLite though and the DB Browser for SQLite within the CS350 tutorial though. It would make the learning experience a lot smoother.
It might be possible if I had more knowledge, but in that scenario, jumping between the YouTube channel, Cloud9, Gitlab, and whatever other resources I might leverage to use SQLite would make things more complicated.
26 Feb 2017, Part B
Ran into seemingly insurmountable problems when CS350 decided to use psycopg2 in its tutorial. Various forums had different solutions and some of it coincided with my own suspicions. Generally, these were:
It was super confusing. At first, I used apt-get and pip, and sudo apt-get and sudo pip, to install it. I ran pip freeze and found it wasn't in the list of installed packages. I tried various things after that and at one point, pip freeze said I had the latest version of psycopg2, but I checked Pypi, and I definitely had the wrong one. I ran sudo apt-get update but it still gave me the wrong version.
I basically ran through permutations of solutions for all three of the above possible problems and finally, got the right version of psycopg2. It took about two hours and every minute grew more and more despondent until that final moment it suddenly worked.
This is how I solve this kind of Python problem(s). I had to do this with NLTK too. It always drains me. Now I need to take a break.
Anyway, this problem prompted me to find out what the differences are between apt-get and pip. Now I know.
26 Feb 2017, Part C
On a tram to friend's for dinner. Put two and two together and figured out that I can use <input type='submit' name='placeholder'>, request.form['placeholder'] and cur.execute("""SQL COMMAND""") to mediate between front end users and database.
Am I right? Is this the standard way to do it? Can't wait to go on with the tutorials and/or figure it out another way.