Some basic Flask Application set-up

This is a brief (always calling three page things brief makes me wonder if I understand the word sometimes.) overview of where things are with the todoList application.

 

Having served Flask on AWS before I kind of knew what I was in for. That said, I was able to successfully follow these brief instructions for serving Flask on AWS in about five minutes. Currently I have Apache serving a super basic flask “Hello World” application.

In that same folder, though, I have a git repo of the todolist application. I figure that this is a simple process, but occasionally miss the FTP plugin for Sublime Text. I have made a couple of modifications to the imports due to lack of thinking on my part – I generally always test stuff in DreamPie and didn’t think that the path was different with different scopes. Got that sorted out, thankfully.

I installed the flask-script and flask-bootstrap modules – basically because I like the interactive prompt for the application that flask-script provides, and I like things pretty and am lazy so I am going to use bootstrap.

Finally, since I am building this webapp from scratch, I wanted to make sure that I have the suggested package pattern. To help do this I have been rereading the flask documentation on packages. I am not sure yet, but I think that the actual flask application is going to basically just be an interface, so it should live within the interface. Not totally sure yet, but I am working on it.

Enter tags.

I created a version two of the database (although it is not actually used in the script, yet, only manually) which includes tags and tag applications. I used a trigger that runs after a successful delete which deletes records of the tag application. That is actually either because of the trigger or the foreign key dependency. Not too sure.

I also created a method that deletes either of the two tables that are created in the upgrade to two. Basically, I had it error out on the second delete statement because of a type, but it had already done the first delete statement. The next time it ran, it errored out because the first statement had completed so there was not a table to delete. I wrapped it in tries because I expect them to be there, but there is a chance they are not.

I finally added methods to interact with tags to my tag interface. Basically everything from getting todo items with the tags to adding, removing, and deleting tags.

I did some basic testing to make sure the trigger statement worked as expected, it did to the basic test. I should probably write a couple of test scripts that run through all of the different functions and how to test them.

I thought this was going to be a no-zero day thing, but it has not due to many reasons. I am still trying to make that a thing, but I am not sure how often I may post depending on the level of home work any new real life job would require.  Yeah, also, I like being with my wife a lot, so I choose her over posting here mostly.

Till next time! (Likely tonight, honestly ūüôā )

 

18 commits today but at a quick stop to refresh.

Since I last updated you I have created the basic ability to add a todo item to the todo list and I have written a method to get the todo items out of the database. I went and checked the bobby tables¬†information to make sure that I wouldn’t enable SQL injection before writing the insert statement, and set some defaults to deny attackers entrance through the queries parameters. (Basically I was afraid that someone may try and inject something that ends the LIMIT part and starts a new malicious statement.)

I then created the basic infrastructure needed for the todo list application. A super basic text based interface (It doesn’t loop yet, but it will format and display the todo list items)

I started to create the second version of the database, but I realized I should probably reread Pep 8 Рthe Python Styling Guide Рbefore I do any more work on the project. I am frankly unsure of naming conventions so have camelcase and underscores everywhere right now.

That’ll likely be another post.

First Github sync

First sync of five commits.  I basically create a database. Yeah, it is not a lot, but it is something.

Originally I had set the goal to make commits with as few lines of change as possible. When I set that goal, I was literally thinking that I would create a commit for every couple of lines that the project grew.

ROFLMAO.  I have a lot more than a 10 lines of stuff for those five commits. My last commit was a 60 line file where I finally added the first code to the repo. The first third of that, though, is comments. And they are interspersed through the rest of the code. Basically it is not a lot of code, but there is a lot of stuff.

A quick walkthrough:

  • README – you know it, you love it. Talks about what the goal is and some general commit guidelines for myself.
  • LICENSE – MIT, of course. ¬†I mean I like writing stuff for me, but I would rather be able to have other people have access to something if it can help them. I want anyone to use this software for anything they can, hopefully not evil.
  • .gitignore – With this recent change to using sqlite the change that I made may be unnecessary.
  • db – FOLDER
    • __init__ the file that lets the interpreter know that this is a module. (It can also be used for other useful things. For instance we may try and get it to automate db loading when importing the db module. ¬†We will see.
    • td_db.py the file which will house most of the methods to interact with the database.

Database data and ideas of future growth.

Okay, so originally I said that I wanted to use MySQL because I had instances available through my hosting provider. After thinking about it, and wanting to choose it, I decided to go with SQLite instead.

Yeah, me wanting to do it was the final decider, but look at what all we gain by using SQLite: It allows this application have its data passed around like a file, it is super cheap, doesn’t run when it is not being used, can be somewhat secure since it does not have a server running, is everywhere in Python books and Android, and, probably most importantly right now, I want to.

Finally I was steered in the direction of SQLite because ultimately I want to build an Android application which is more than just an interface to a remote mysql server.

Iterative Development and my todo list.

Iterative development is the process where you make frequent changes to your code base, constantly growing it.  Taking this concept to its logical, absurd, extreme would mean that I create a release for each small improvement to my todo list.

Currently this is my plan. v0.1 will likely be a Python script that creates a basic database and allows someone to add items to the list. v0.2 will likely allow the user to mark a task as complete. This numbering/release scheme will continue through each iteration of feature

 

 

Restarting my todo app.

I have attempted several times in the past to figure out a todo application that I would want to use, everything from the database in the backend to the API to the web client to the mobile client to everything.

I am officially restarting this quest. Everything from planning to implementation, to update and maintenance I am going to try and write something about.

Once I decided to restart this endeavor with my bigger-than-last time skillset I decided to start at the very beginning: Planning the object UML (I think it’s UML. Basically I am planning the values and methods that will make it up) I have not gotten very far as I am currently debating on trying to make the todo list itself a parent item to every item on it, or if they should not share inheritance. I think I will not have them share inheritance, rather the todo list will be full of methods for planning, moving, and fitting the actual todo items and sub items. (Maybe with projects, that seems like a should have too.)

As you can see, I still have a lot of planning to do, so I am going to get to it and will update you again within a week!

Edited to add: Some things that I forgot to mention in the first post. I am going to start by using a mysql database, as that is what I have access to on my hosting provider. The book that I read, Head First Android, touched on creating adapters. I am pretty sure that I can get the adapter written, assuming (and I have to imagine) mysql is supported on Android. If not, I may do something with just API calls and an Android client, microservices style.