What I'm Thinking

Pass
10 September 2020

I am embarassed to say that I have only just lately discovered pass. Can’t believe it took me so long, but now that I have, very happy with it. Nice and simple to make use of it. I highly recommend taking a look at it.
Django environ makes use of setdefault so if you are looking to change a settings value in a environment file and are within a virtualenv you may need to exit/enter the virtualenv for the change(s) to take place. It took me a while to figure this one out.
When making use of AWS CloudFormation there is currently a file size limit of 51200 bytes on stack templates. On a reasonable size setup you can quickly hit that limit using JSON format, while YAML format will take you a while longer. A quick example of a file size comparison between the two file formats; stack.yaml - 3.3K stack.json - 5.6K If you want to convert from JSON to YAML you can do that with the following python code snippet. ... Read More

Tarfile Tip
30 November 2016

Working with tar files and attempting to create a py.test fixture of a tar file and I ran into an issue. I’m using TarFile package on python 3.5 My initial fixture was setup as; @pytest.fixture def file_tar(tmpdir, tmpdir_factory): fn = tmpdir_factory.mktemp("tar").join("test.tar") tf = tarfile.TarFile(str(fn), "w") p1 = tmpdir.mkdir("src1").join("test1.txt") p1.write("text 1 content") tf.add(p1) p2 = tmpdir.mkdir("src2").join("test2.txt") p2.write("text 2 content") tf.add(str(p2)) tf.close() return fn But I ended up with an empty file in the tar’d file fixture, and that was causing issues when attempting to extract the contents of the tar’d file. ... Read More
Came across a funky error attempting to upload a package to PyPi using Python 3.5 $ python setup.py sdist bdist_wheel upload ... Traceback (most recent call last): File "setup.py", line 45, in <module> install_requires=['django>=1.10'] File "/usr/lib64/python3.5/distutils/core.py", line 148, in setup dist.run_commands() File "/usr/lib64/python3.5/distutils/dist.py", line 955, in run_commands self.run_command(cmd) File "/usr/lib64/python3.5/distutils/dist.py", line 974, in run_command cmd_obj.run() File "/usr/lib64/python3.5/distutils/command/upload.py", line 63, in run self.upload_file(command, pyversion, filename) File "/usr/lib64/python3.5/distutils/command/upload.py", line 162, in upload_file body. ... Read More
Full templating functionality in our website. We want to be able to pass in data to the templates and determine which templates are to be used when generating our response. This is a continuation of the Golang Web Apps and the source code can be found at https://github.com/reinbach/golang-webapp-guide. To better organize the code we move all the templating functionality, the templates, and the static files into a separate directory. Which now gives us the following file layout. ... Read More

Golang - Web - Guide
3 April 2015

A multi-part article about developing a website with Golang, with each article about a specific piece of functionality that is common for a complete website. Previously I have done a large amount of development with the Django framework. I like it because it has everything and it allows one to develop a website quickly, and so there will be a lot of influence from that in these articles. The reason I made use of Golang is because I wanted to see how simple it would be to implement a lot of this functionality with mainly the Golang standard packages. ... Read More
The scenario is that we want to use formsets on a model, but the model has a foreign key, and we only want a subset of the elements referenced by the foreign key. i.e. We don’t want all of the options returned by the foreign key to be shown. I really like the Django class based views and use them as much as possible. I find that they make my life a lot easier. ... Read More

Django - Recursive Templates
23 December 2014

The scenario I had was that of a table showing a list of accounts and these accounts had subaccounts. I wanted a simple way to display these subaccounts, but indented slightly relative to their parent. And I did not know the number of levels involved. The following is the way I went about solving this in this instance was to call django templates recursively. Create a templatetag to handle the display of displaying indentation character the correct number of times; ... Read More

Golang Web Apps
5 April 2014

This is a short simple guide about using golang for web application development. The idea is that we start with the straight golang net/http package and slowly develop a more complex web application each time as our needs grow. Adding a component, or functionality to the system to solve the identified need. All code can be found at https://github.com/reinbach/golang-webapp-guide Basics Firstly we start with the absolute basics. Which is to handle a request and return a response. ... Read More