Creekside Blog


The Psychology of COVID

I ran across a couple of articles in Knowable Magazine. I've often wondered how the government and the "main stream media" attempts to engineer the response to the pandemic could have failed so miserably. These articles give some insight in to this along with helping to answer how "alternative" media sources didn't perform too well either. Pandemic psychology: Nothing new under the Sun - Steven Taylor Question the ‘lab leak’ theory. But don’t call it a conspiracy. - Ivan Oransky These articles are among many Knowable magazine has related to these topics. I don't know much about this publication's biases or intentions, but these are good "make-you-think" articles. They raise points that should help you analyze your thinking on any number of polarizing issues. I had originally intended to comment on the articles and I'll probably do so in the future, but the overarching need is for people to form their opinions logically. Don't be afraid to voice an opinion that might be called extreme if logic takes you there, but at the same time don't let yourself get overly influenced by people on TV who like to loudly proclaim inflammatory material and call people names. They aren't trying to educate you; they are trying to either scare you or make you mad in the pursuit of ratings. 
Bootstrap, Datatables, JavaScript, and JQuery

in my previous iteration as a web developer, "back in the day", things looked quite a bit different than they do now. Mobile phone wise, about the best thing going was a Blackberry, so mobile browser support wasn't given any thought. Its a different world today. I'm setting up an app for my homeowners association and one of the board members remarked that it looked like crap. She doesn't have a computer and her only viewing of the site was on her phone. I'm sure a lot of homeowners will be in the same boat when this goes live. Without acceptable mobile support the "buy-in" rate isn't going to be very good. I had had a conversation with a colleague who is a web developer and he mentioned Bootstrap. As if I was someone waking up from a fifteen year coma, I had never used it before, but I was quickly able to get the basics from a W3schools tutorial and was able to retrofit my blog and HOA sites. These now scale quite nicely to a mobile display. Its not perfect, but its pretty darn good and I have a lot of tutorial left, so I'll likely pick many useful tricks. I also went back and incorporated Datatables and tooltips in my HOA app and they play well with Bootstrap also. I'm using Bootstrap 4 which utilizes jQuery. I see Bootstrap 5 is using plain vanilla Javascript. Things have a way of coming around full circle.  
A Site Email "Gotcha"

I ran into an issue when trying to set up email for the site. My specific task was setting up the password reset functionality but it affects email in general.  My goal was to use AWS Simple Email Services aka SES. I found a module called "Django-SES" which  which was claimed by several bloggers to be the easiest way to add email to a Django site. In fact it was very easy and it worked out of the box on my dev site. When I deployed to the "serverless" lambda environment, I ran into an issue. When I tried to send an email, I got a an endpoint timeout. So, I'm trying to figure out why this is happening. Its pretty obvious that I'm not reaching the email server. Without getting into specifics of my network topology, my application is running on a lambda behind a VPC. Most of my searches are saying that I need a NAT gateway. The problem with that is they are relatively expensive. The other option is a relatively new feature that AWS has set up that provides Endpoints for common AWS services. It just so happens there is one for email-smtp.us.-east-1.amazonaws.com. After setting this up and changing a few security rules I should be good to go, but still no joy. After looking through the logs I realize my problem. Django-SES wants an endpoint of email.us-east-1.amazonaws.com for my region. There is no Endpoint service provided for this. So back to the original SMTP Django email backend and all is well. The moral of this story is that just because some bloggers claim something is the "easiest way" or whatever, doesn't mean its going to be the best solution for your situation.  
Excellent Django tutorial

A vey good Django tutorial can be found at https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django".
Zappa and Django installed

So, following the three previously mentioned web sites and "Google engineering" the occasional issues that popped up, Zappa and Django were installed on my AWS Cloud9 instance. My first app is this blog. I was able to use my existing RDS MySQL database, along with most of my existing templates Django has a lot of builtin features. One example relates to models and database tables. One can define the table items in the models.py file for the app and run the migration and it will build the table for you. This is not an uncommon feature for MVC or MVT platforms. I performed this operation and it worked perfectly, but I was curious about what options I had if had wanted to use my existing table from the Chalice project.  It turns out that I could have run manage.py with the "inspectdb" option and it would have spit out the model definitions for all the tables in the database. One can then just add these definitions to the models.py and keep on going.  This wasn't a big deal with my little one table blog, but this could be a massive head start for someone porting over a large multi table app with lots of relationships. Using the generic views, one could have CRUD functionality set up very quickly.
Sources used to set up Zappa and Django

I bounced between the follwing links for how to set up Django on AWS Lambda via Zappa: https://www.section.io/engineering-education/deploying-a-serverless-django-restapi-with-zappa-on-aws/ https://auth0.com/blog/deploying-django-restful-apis-as-serverless-applications-with-zappa/ https://www.agiliq.com/blog/2019/01/complete-serverless-django/ I suggest trying to get a handle on what you are doing on each step vice just running blindly through these tutorials. Getting the database to connect correctly is an issue and I went straight to MYSQL rather than using SQLite.
Going with Zappa and Django

Chalice is cool and it has a Flask like feel to it, but after running into issues with Cognito while trying to set up security on my Chalice based blog app, I decided to give Zappa and Django a shot. I'm sure someone who is a bit more savvy with Chalice could make this all work, but at the end of the day, I had to move on and get things done. When I took the decision to move to Zappa, I then had the opportunity to use Flask or Django with other options such as Bottle also available. I decided after my previous attempts to go with Django since it had an onboard security structure. It is is extensible such that I can use external authentication and authorization solutions such as Auth0 or Cognito if get froggy later on. I also wanted to stay with AWS serverless and Python, so, given these constraints, this appears to be the best solution.