We love pip and Fabric for Django deployment. You can see our boilerplate fabfile.py here. Pip, however, isn’t safe to run in an automated fashion. If you attempt to switch branches or repos for one of your editable requirements, you’ll be presented with this input:
NAME
yes - output a string repeatedly until killed
SYNOPSIS
yes [STRING]...
yes OPTION
DESCRIPTION
Repeatedly output a line with all specified STRING(s), or `y'.
...
I have the most success with the “wipe” option for pip, so now we can simply run:
yes w | pip install -r requirements.pip
This answers w to any prompt that pip displays, making it much more ...
I really like supervisord for long-running process management. It is Python, so it is easy to install and it is easy to script with tools like Fabric. Lately I’ve been deploying smaller Django/WSGI sites with Green Unicorn behind Nginx proxied over a Unix socket which makes for a nice little setup on shared hosting and RAM starved VPSes.
After installing supervisord with something like sudo easy_install supervisor, you’ll want to make sure it runs after you reboot your machine (and gets restarted in case it crashes). If you are on a Linux system with upstart (and have root access), you can bypass the ugly init scripts and use this simple file placed in /etc/init/supervisord.conf to manage your supervisord process:
description "supervisord"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
exec /usr/local/bin/supervisord --nodaemon --configuration /etc/supervisord.conf
June 16, 2010 |
django, review |
Only one comment so far.
I just finished reading the copy of Django 1.1 Testing and Debugging by Karen M. Tracey provided to us for review by Packt Publishing. For those of you who don’t know, Karen is a core developer of Django and her knowledge and experience in the framework shines through in this book.
This is a great book for people who want to transition from being a hobbyist tinkering on Django sites to professional developers. It will be a lot to digest for a newcomer to Django and might not contain much new information if you’ve been working with Django for a while (and writing tests for your code). The book covers:
May 24, 2010 |
company news, django, gondola |
4 comments
I’m pleased to announce that Gondola for Real Estate, our GeoDjango-backed real estate CMS is publicly accepting new customers. A couple weeks ago, we quietly re-launched gondolacms.com with some details about the platform and what it has to offer, as well as some sites that have been built on it over the last few months.
History
A couple of years ago, we were building websites for some local real estate agents and realized that what they wanted couldn’t be shoehorned into the popular CMS frameworks available at the time. Somewhat reluctantly, we set out to reinvent a CMS that met their needs written in Django. Eventually, the client-specific bits were extracted and Gondola was created. It has been under the radar for the last few months while we tweaked the system with a small group of early adopters and it is to the point now where we ...
May 18, 2010 |
company news, django |
No comments yet.
Today, we are launching a new offering at Lincoln Loop, development services paid by the sprint. Previously, our typical engagements involved a (sometimes lengthy) discovery, estimation, and bidding process. Lately, however, people have been asking us to jump in with both feet and help them get started immediately. For those people, we think paying for services on a sprint-by-sprint basis will be a great option.
At the beginning of every sprint, you’ll provide us with a prioritized list of user stories, features, or tasks that are to be completed. Our team then dives into the project for a 2 week long focused burst of work. Our goal is to complete as much of that list as possible in the time allotted for the sprint. For development work, that means fully-tested features ready for production. During the sprint, we can provide not only our expertise in Python and Django, but ...
Homebrew seems to be the hot new package manager for OS X, so while setting up a new system last night, I figured I’d see how it handled installing all the external libraries required for GeoDjango. The answer I quickly found out was, “extremely well.” Here are the steps:
$ brew update # make sure all your formulae are up to date$ brew install postgis # this will handle installing postgres, geos, proj4, and postgis$ brew install gdal
That’s it. Three (two if you don’t count the update) steps to GeoDjango goodness. Color me impressed.
February 12, 2010 |
pro tip |
Only one comment so far.
Here’s one I struggled with a bit while upgrading lincolnloop.com yesterday.
Scenario: You need to take your site offline and want to redirect all its traffic to a “down for maintenance” page. For search engine friendliness, that page should return a 503: Service Unavailable status code. Here’s the (not entirely intuitive) way to do that in Nginx:
server {
listen 80;
server_name mysite.com;
root /var/www/mysite.com/;
location / {
if (-f $document_root/maintenance.html) {
return 503;
}
... # the rest of your config goes here
}
error_page 503 @maintenance;
location @maintenance {
rewrite ^(.*)$ /maintenance.html break;
}
}
Now whenever you need to take your site offline, simply create the file maintenance.html in the $document_root (in our case, /var/www/mysite.com). If the file exists, Nginx will serve it with a 503 status code, if not, it will proceed as usual.
December 18, 2009 |
code, open source |
15 comments
Etherpad is an amazing real-time collaborative editor with a very low barrier for entry (no logins, no additional software, etc.). In case you missed it, Etherpad was acquired by Google and after a community uproar decided to release their code as open source under the Apache License 2.0.
We were excited to get it up and running for our own internal use. What follows is a step-by-step guide of how we proped it up on our development servers.
Caveats:
We’re not Java guys, so if there is something we could be doing better, let us know.
The default setup of Etherpad is RAM hungry. Make sure you have at least 256MB free before you get started.
Our instructions are Ubuntu/Debian specific, but should be easy to translate to a different distribution.
Step 1: Get the Requirements
mkdir /opt/webapps/etherpad/ && cd /opt/webapps/etherpad/
sudo aptitude install ...
As Lincoln Loop has evolved and grown over the last year, we’ve learned a lot not only about software development, but also about all the things that accompany it like budgeting, estimating, and scheduling. Probably the most important one is the ninety-ninety rule. It states:
The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.
The lesson here is that when you think you are almost done with a project, chances are there is still a lot of work left to do. Knowing the rule is all well and good, but it doesn’t help you overcome it. The important skill is being able to adjust your thinking and planning to match the estimated amount of work to the actual amount of work. When you can do this, budgeting ...
October 15, 2009 |
django, review |
Only one comment so far.
Packt Publishing was nice enough to send us a copy of Django 1.0 Template Development by Scott Newman for review recently. I get most of my technical information via the web, so picking up a technical book was a nice change of pace. This is a well written and enjoyable read for people looking to learn a little more about Django than what is provided in the Django tutorial.
Based on the title, I expected a thorough write-up of the template system for front-end developers. With the way Django was designed, template developers need little, if any, knowledge of Python and what goes on under the hood with Django requests. I was surprised, however, to see that pure front-end (HTML/CSS/JavaScript) developers were not the target audience of this book:
This book is for web developers and template authors who want to fully understand and utilize the Django ...
In part 1, we showed how we use Fabric to update and deploy Django sites to our development server with a single command. This works great when you only have one developer pushing changes to the server, but what happens when multiple committers need to update the development server?
Linux File Permissions
Typically, the default permissions for newly created files are readable by everyone and writable by the owner (644 or -rw-r—r—). These permissions are determined by the processes umask, with the default being 022. Since we want multiple committers to be able to write to files on our development server, we need to change that to 002, creating group-writable files (664 or -rw-rw-r—).
The standard way to do this is to add the line umask 002 to /etc/profile. While that works great for interactive shells, it does not get called on non-interactive shells (the kind that ...
We’re firm believers in the practices described by the Continuous Integration method of software engineering. Among those are:
Maintain a code repository
Automate the build
Automate deployment
We use git for our code repositories and Fabric to automate our build/deployment process. The tiny bit of overhead it take to write out a Fabric script pays off very quickly against the tedium and error-prone practice of manually building/deploying. In building our “fabfile”, we encountered a couple of issues that took a little head-scratching to work out.
Git and SSH Keys
Git, like Mercurial and others, confirms your credentials via an private/public key pair when used over SSH. We use gitosis to manage our private repositories, so managing everyone’s keys isn’t much of an issue. The problem comes when developers need to start pulling the repository on different machines. Our developers all push to a central ...
Inspired by Eric Florenzano’s talk, Using Django in Non-Standard Ways (slides in PDF) at DjangoCon and the announcement of Tornado (tornadoweb.org), I decided to try building a small application using the Django Form library and Django ORM inside Tornado. The process proved easier than I expected, especially with Russell Keith-Magee being able to provide guidance on demand.
Step 1: Create Your Database
While Russell explained that it should be possible to get commands like syncdb running outside of a traditional Django project, it was outside the scope of this small experiment. Instead, I created a Sqlite database manually. For those of you that have forgotten how to do this, this will get you started:
Last month, Lincoln Loop gave a talk at EuroDjangoCon about customizing the Django admin interface. After presenting some of the admin customizations we had done on Gondola, I had a bunch of people get in touch with me asking me to do a write-up about how it was done. After about 8 months of heel-dragging, I finally took the time to do it in presentation form.
Our talk was divided into two parts. First our User Experience Director, Michael, gave an overview of user interface design and why it is important, pulling examples from some real-world interfaces. Comparing the default Django admin to a custom built application specific interface was an intentional cheap-shot to get people to think outside-the-box when working with the admin. Our argument was that it is possible to recreate any of the example interfaces while still leveraging some of the power baked into django.contrib.admin ...
I’ve always disliked the way named anchors (<a href=”#name”>...</a>) behave in browsers. It jumps your viewport to a different part of the page, but it’s rarely obvious which section you have landed on. If the page is long enough, the referenced section will start at the top of your browser, but where does it end? If the content is towards the bottom of the page, it may not be at the top of the page, but somewhere in the middle. And what if your content is in two columns? Or a table? What you’ve linked to becomes totally ambiguous.
Sphinx uses named anchors quite a bit, so I wanted something that would improve their usability for Django Best Practices. That’s when I dug up this clever little jQuery snippet from our code vault.
// highlight and fade background on named anchors// requires jquery.color.js ...
One of the things I love about Python and Django is the philosophy that there is one obvious way to do things. Standards make it easy to dive into other people’s code and figure out what is going on pretty quickly. As with anything under active development, however, those standards are subject to change over time. What was best practice for building sites with Django 0.91 is significantly different than building sites with Django 1.0. Better tools and more experience allow us to refine our processes over time into a set of best practices. While both Python and Django are very well documented, much of the experience and wisdom that is outside the scope of the official documentation is not.
Blogs are Bad for Documentation
Most of this information lives scattered across blogs ...
Yep, it is. These little snippets aren’t much, but they speak volumes. The White House is using open source software, specifically the Apache web server, the DrupalCMS and the jQuery javascript framework.
So What?
Open source adoption is most definitely on the rise, but it still has a stigma attached. The idea that Microsoft and ...
December 23, 2008 |
django, screencast |
6 comments
Satchmo is an amazing E-Commerce engine built on top of Django. After struggling in the past with difficult packages like ZenCart and OSCommerce, Satchmo’s ease of customization make it a joy to work with.
Unfortunately, all the features can make the administration interface a bit daunting at first glance. I created a screencast to help shop owners get started with the process of adding products and product variations in Satchmo. I’m using the latest release as of this writing (0.8.1).
In the process of prepping Gondola CMS for public consumption, we’ve grown from having a developer (me), to having a development team. One pain point that quickly arose was the amount of time it took for new developers to setup a local development environment. In addition to our source code, the project depends on nearly a dozen other Django apps and Python packages. Initially, we simply tracked the requirements in a text file, but it required a lot of manual work to get them downloaded and installed.
Necessity is the Mother of Invention
Of course, this problem has been tackled many, many times before1. As I looked into what was out there, my first thought was that most of the existing options were far too complex for our needs. If I didn’t grok a system after clicking around the docs for 10 minutes or so, I moved ...
We all know not to serve static media (images, CSS, Javascript, etc.) in production directly from Django. Thankfully, Django gives us some nice settings like MEDIA_URL and MEDIA_ROOT to make serving them a lot less painless. Lately, however, I’ve come to realize that these settings shouldn’t really apply to all static media.
Not All Static Media Is Created Equal
Static media really comes in two flavors. Media that is part of your site like your stylesheets and user generated media or files that are uploaded to the site once it is live. We don’t want to serve all this media from the same place for a couple of reasons:
Our source checkouts shouldn’t be crufted up by stuff our users are uploading
User generated content and source code should live in two different places on the filesystem
We could fix the first problem with some .gitignore ...
Our first iPhone development project hit the App Store last week and is already over 1k users! Check them out @takemyspot #iphone #geodjango
Pete, 3 weeks ago
Troubleshooting OpenID is just like user/password. Except you have 5 of them and and you don't know which one is failing, and 3 login pages
Pete, 1 month, 1 week ago
The final tally is in. 8 Lincoln Loopers attending DjangoCon. 3 US, 4 EU, and 1 NZ. Looking forward to it!
Pete, 1 month, 2 weeks ago
Twitter / Dustin Curtis: I'm flying to Madrid tomor ... Dustin Curtis travels to Berlin, Bangkok & Madrid in exchange for design services as the result of a late night tweet. Pete, 1 month, 2 weeks ago