Hi, I'm Harlin and welcome to my blog. I write about Python, Alfresco and other cheesy comestibles.

Redirecting to harlinseritt.com in 3 seconds ...

Python - A Simple Method for Refactoring Your Code For Extensibility

I am talking to the beginning Python programmer here. Or to someone who has avoided object oriented programming and has used procedural programming. Or to someone who mainly uses Python to write scripts -- though you can definitely use the ideas I have here for bigger applications. In fact, you will ...

Read More

Python - Intro to web.py

Intro to web.py

I was first introduced to web programming some time around 2003. At the time, the hot language/platform was PHP. I had begun to learn Python because I was interested in writing a monitoring tool which Python seemed to be well suited for. At that time ...

Read More

How to Get a Python Development Job (Or why that kind of thinking may not be best)

I get asked this one quite a lot. I would love to have a sure-fire answer that would help you get a Python Developer job but I don't think I have an answer really. To be honest with you, I have never had a job where I was a ...

Read More

Python + Gunicorn + Nginx - A Simpler and More Performant Method to Deploy your Django Projects

Last week, I posted an article that had to do with hosting your Django projects with gunicorn and Apache. Today, I want to mention an alternative to Apache called Nginx. Most of you know that Apache is probably the most used web server on the planet and has been around ...

Read More

Python + Gunicorn + Apache - A Simple and Performant Method to Deploy your Django Projects

Note: This is not a discussion about Apache being better than its competitors. It's only about how to set up Django, Gunicorn and Apache.

I used to host my Django projects with mod_wsgi and Apache. It worked well for most things. Some of its advantages are that it's ...

Read More

Python + Django How to Test Views

Today I wanted to go over how to use Django's web client testing features. It's a fairly simple thing to grasp how to use Python's unit testing to test functions and procedures but I am finding that a lot of Django beginners are not sure how they ...

Read More

Python + Django - How to use the built-in authentication system

In this article I want to show you how to use the built-in authentication system that Django provides for you out of the box. You could build your own authentication functionality into a view by doing the following:

  1. Check to see if the request.user is authenticated.
  2. If the user ...

Read More

Python - Coding for MongoDB


MongoDB is an open source database that uses a document-based model. A RDBMS system like MySQL, Postgresql or Oracle uses an organized system of tables that have a defined set of columns and functions that relate to each. Instead of tables and rows, MongoDB uses the concept of collections ...

Read More

Alfresco - Alfresco Setup for Sysadmins and QA Testers

I have a few conventions on the organization of Alfresco installations to make my job (and life) easier. Since I may be also testing multiple Alfresco installations, I try to setup installs in a particular way so that different versions are easier to find. Also, it helps to have some ...

Read More

Python - How To Get Started

I get asked quite often something along the lines of:

I am new to programming. I would like to learn Python and/or Django. What is the best way for me to go about learning it and mastering it? or Can you recommend any good learning resources?

The answer may ...

Read More

Python - How to Work with MySQL

What we need:

  • Python 3.6.3
  • mysqlclient module
  • MySQL server
  • mysql-workbench

First, make sure you install MySQL server and ensure it's running. Instructions on how to install MySQL server:




To install the mysqlclient module, you'll first need to install MySQL server (and ...

Read More

Python - How to Work with SQLite3

(see http://sebastianraschka.com/Articles/2014_sqlite_in_python_tutorial.html)

What we need:

  • Python 3.6.3
  • sqlite3 module (should be included in Python 3.6.3)
  • sqlitebrowser

On Ubuntu to get SQLite Browser you can install it from the command line:

# sudo apt install sqlitebrowser

If you're on Mac OS X ...

Read More

Alfresco - Installing Community 5.2

I'm creating this post as a bookmark of sorts. If you've arrived here, no need to worry with this one unless you are interested in getting Alfresco Community installed. Keep in mind that there are Alfresco Enterprise and Community installs. If you don't have an Enterprise license ...

Read More

Python - All Things Being Equal: "is" vs "=="

In the world of drink branding it is very important that all of your products of the same line of drinks taste exactly the same. Companies like Coca Cola, Pepsi, Budweiser and all the rest go through great lengths to make sure that their drinks taste exactly the same. This ...

Read More

Python + Alfresco CMIS Rest API

I haven't had much time to spend on Python but I did want to let you know about a project I am working on the side.

It's called Alfresco API Python (or alfresco-api-python). I wrote a post a few months back about CMIS (cmislib to be exact). For ...

Read More

Python - How to Use Underscores in Your Code

Note: This post was derived from Dan Bader's post on underscores that explains the subject in a lot more detail. If you are interested in reading his article, go here.

If you're a new Python programmer, you are likely encouraged to have a look at other programmer's ...

Read More

Python - Comprehending List Comprehensions

List comprehensions have been in Python since 2.6.x. If you're not using list comprehensions with Python, you are likely using a for statement and iterating through an iterable like this:

trees = 'oak', 'pecan', 'hickory', 'cherry'

for tree in trees:



You ...

Read More

Python - PEP 8 Series - Whitespace

Python is one of the few languages out there which takes whitespace into consideration for the purpose of readabilty. This is why this code is more elegant and flowable as you type:

def add_and_double(num1, num2):
    addition = num1 + num2
    product = addition * 2
    return product


public int (int num1, int ...

Read More

Python - How to Set Up a Simple HelloWorld Django App

The purpose of this post is to provide a set of instructions to create a simple helloworld app in Django. This app can then be used for testing purposes in other posts I've written.

Set up virtual environment:

# pyenv global 3.6.4
# pyenv virtualenv deploy_django
# pyenv local deploy_django ...

Read More

Best Practices for Using Active Directory with Alfresco

Normally when I help a user that involves issues with setting up synchronization of users and groups, the customer has settings that are extremely generic like these:


ldap.synchronization.personQuery=(& ...

Read More

Python - How to Group Imports

In case you were ever wondering, here is the standard way to group your imports.

# Standard library imports
import os
import sys

# 3rd party modules
from django.http import HttpResponseRedirect
from django.shortcuts import render

# My project-wide modules
from blog.settings import THEME
from lib.util import get_http_referer

# From separate ...

Read More

Python - How to Use the Zip Function zip()

Have you ever had the need to iterate over two or more equal-sized lists?

Let's say you have two lists:

>>> cats = ['Koko', 'Gracie', 'Cheshire']
>>> foods = ['dry cat food', 'raw chicken', 'wet cat food']

We can then iterate over them like so:

>>> for c, f in zip ...

Read More

Python - PEP 8 Series - Indentation

Consistent indentation of code is key for Python as you can get some painful indentation errors. If you really want to avoid that problem all together, always use 4 spaces for indentation. Also, avoid tabs, you don't need them.

Keep your lines at 79 characters or less. Continue to ...

Read More

Python - The Right Way to Ask Questions that Get Answers

Starting off in any endeavor -- especially as it relates to technology, you're going to need to ask questions so that you can get answers and learn. Sure, you can't avoid reading the manual or googling but often (especially in the beginning), you'll need to ask questions so ...

Read More

Python - Using the -m Option to Run Modules

Do you ever make use of the Python interpreter's many options? These are often overlooked but if you ever take the time to see what's available, I think you'll be pleasantly surprised.

If you call python from the command line using --help, you'll see a number ...

Read More

Python - A Very Basic Example of Functional Programming

Certainly by now you have heard of functional programming. When most new and intermediate developers hear functional programming, they very quickly think of javascript and maybe some other programming languages that are built specifically to use the functional programming paradigm.

Were you aware you can do this with Python? Functions ...

Read More

Python - Understanding Querying in Django

If you're an old guy like me, you are probably used to SQL queries. You can certainly use them with Python to retrieve data from RDBMS servers but they can be a little problematic for a number of different reasons. They can be difficult to implement without writing a ...

Read More

Python - Simplest Django Tutorial Ever

I wanted to write up a very simple Django tutorial that will show you the workflow behind creating a very simple CRUD app. The workflow is repeatable of course. You can use it to build more functional apps.

The steps below will show you how to build a simple ToDo ...

Read More

Python - Using @property and @setter for Data Encapsulation

I came to Python after coding in Java for a couple of years. That wasn't a very long to learn the ins and outs of Java or any other programming language but it was my first one where I had built up a measure of proficiency. When it comes ...

Read More

Python String Formatting - More than One Way to Do It

By now, you've probably seen one of the guiding principles of the Python programming language when running "import this" in your interpreter.

Python's mantra on ways to get things done in the languge has been: "There should be one-- and preferably only one --obvious way to do it ...

Read More

Python - Using the timeit Module for Quick Speed Evaluations

The timeit module allows for a developer to time a few lines of Python code. It can be used as either a Command-Line Interface or a callable method in a Python script.

From the command line:

$ python -m timeit "[i for i in range(10000)]"

100 loops, best ...

Read More

Python - Args! and Kwargs! How do I Use Them?

Have you ever looked at Python code that included *args and **kwargs and wondered what in the world these things are? Python is supposed to be quickly readable to someone either new to programming or someone coming from another programming language. These look weird. What gives?

Well, the *args and ...

Read More

Python Package and Version Management - Which Should I Use?

There are a number of similar-sounding Python packages used to manage either versions of Python or packages in a project. If you're not familiar with them, it's easy to get them confused.

So far, I've seen these:

  • pyenv
  • virtualenv
  • virtualenvwrapper
  • venv
  • pyenv-virtualenv
  • pipenv

No doubt, there are ...

Read More

Python Decorators - A Simple (almost!) Example

I'm not sure if you've ever noticed but for me, I've found Python decorators are a very tough subject to understand. This is especially true if you are completely new to them. If you do a search for a simple explanation of Python decorators you will find ...

Read More

Python - Simple and Concise Logging Setup

Here is a simple and concise logging setup for a Python module:

#!/usr/bin/env python
A logging demo that shows most of all you'll ever need to know
concerning Python and logging.
import logging
import sys

logger = logging.getLogger(__name__)
log_format = logging ...

Read More

Python - Basic Unit Testing and Test Driven Development

In case you're unfamiliar with it, code testing is proving your code works as expected. Unit testing does this too, of course, but in much smaller bites. There's also this other thing called Test Driven Development. There are also many other subjects that have to do with code ...

Read More

Python - How to Use Counters to Make Counting Easier

One use case for dictionaries is to pull data from a file or other steam and make a count of occurrences of substrings.

The Counter object is available for quick and easy calculations based on a list of objects and their counts.

Python's Counter object is an unordered collection ...

Read More

Python - How to Stack the Deque - Working with Deque Data Structures

A deque object is similar to a stack or a queue and is initialized left-to-right from an iterable value (or empty). In case you're wondering, deque is pronounced "deck" and stands for "double-ended queue."

Deques are thread-safe and memory efficient. They can be appended, extended or "popped" from either ...

Read More

Python - Namedtuples Examples

Namedtuples are tuples turned into convenient containers for simple tasks. The standard tuple will only have integer indexes for accessing individual members. For example:

>>> trees = ["pecan", "oak", "hickory"]

To access these individually, I would need to do:

>>> trees[1]

Namedtuples are tuples that allow you to access ...

Read More

Python: How to Set up Markdownx for Django

I am working on a blog app written with Django.

I've decided I don't want to deal with TinyMCE as the editor any longer and prefer to write it using Markdown.

I've found what appears to be a decent Markdown module for Django projects called MarkdownX. I ...

Read More

Understanding and Handling Bytes and Strings Issues When Converting to Python 3

I talk a good bit about CMIS (Apache Chemistry) and Python on this site. In case you're not familiar, CMIS (Content Management Interoperability Services) is a standard enabling information and content sharing between Content Management Systems. It can be used with a number of different CMS (or ECM if ...

Read More

Python: How to Merge and Sort Dictionaries by Values

If you ever get two dictionaries that you would like to merge together, you can do so with the "**" operator. How does that work? The "**" operator takes a dictionary and extracts its contents and passes them as parameters to a function.

Consider that our person has some keys ...

Read More

Python: How to Make Use of Constants and Assertions

I knew there was no such thing built in to Python for one to create a constant but of course, I happened to find a hack by Alex Martelli here.

Copying verbatim and shamelessly, here it is:

# Put in const.py...:
class _const:
    class ConstError(TypeError): pass
    def __setattr__(self ...

Read More

How to Get Django and ElasticSearch to Play Together

Ok, I like the idea of NoSQL -- even if there are very few use-cases that really demand it. Honestly, you can use an RDBMS like Postgresql to handle most use-cases instead of going the NoSQL route. Reasoning aside, there is a part of me that really likes it.

I like ...

Read More

Python + Alfresco: How to Get Document Information Using CMIS

Recently a customer asked for a way to query the Alfresco database for document information. Database queries are generally not supported either for transactions or just as read-only queries.

First off, the Alfresco database is very normalized and designed more for efficiency and performance but not so much for readability ...

Read More

Understanding Pythonic Truthiness and Noneness

I decided recently to pay for a class from Talk Python. I did this to better my skills in Python and to evaluate Michael Kennedy's Python courses. The subjects for his courses seem really interesting and if they pan out, I feel these could be very useful in getting ...

Read More

Python + Alfresco: How to Find Documents by Document Type Using CMIS

I like playing with the new Alfresco model manager. Well, at least it was new in Alfresco 5.0 and here we are now on 5.2.

I have an old system where I upload a lot of PDF files. I found an old model (techbooks) on a 5.1 ...

Read More

How to Use Source Code Analyzer PyLint

Pylint is a Python source code analyzer that looks for programming errors, helps enforce coding standards and looks for bad smelling code.

Pylint has a lot of rules that are active out of the box. Still, you can configure which ones you don't need by editing a pylintrc file ...

Read More