Django Advice
stevelosh.com
stevelosh.com
I noticed he used puppet and fabric in this article so it made me interested what puppet it doing better for him than fabric.
Is there a repository of examples? Like just bootstrapping a debian box with nginx/apache/postgres (or mysql)?
Thanks!
Puppet is declarative, Fabric is imperative. With Puppet I can say:
Make sure the directory /var/www/foo exists with permission 755 and owner foo.
Make sure the nginx vhost "foo.conf" exists in sites-enabled with content X, and this depends on /var/www/foo existing.
With Fabric you have to handle all the edge cases. What if /var/www/foo already exists? What if it's owned by someone else? You have to manually code all the 'mkdir' and 'chmod' commands instead of just saying "this directory should exist like this".Right now there's no public example repo, but I'm planning on cleaning up and open-sourcing our Puppet/Django/Vagrant skeleton this week so we can use it during the Django Dash.
[1]http://ericholscher.com/blog/2010/nov/8/building-django-app-...
I never used 80% of tmux's features, so the simpler tools are better for me. If you're a tmux power user DVTM+dtach might not work for you.
dvtm: http://www.brain-dump.org/projects/dvtm/ dtach: http://dtach.sourceforge.net/
But I still don't think Vagrant is that big of a help. I agree that compiling stuff like PIL on OSX can be a bit of a bother, but on production machines it's no bother at all.
And developers usually have to do it once, as, at least in our company, they do not change the projects they work on that often, but rather do them from start to the finish (we find it more productive this way). PIP requirements file with proper package versions is a must of course (Fabric deployment). As is staging server, but speaking from the experience - it's just a precaution, it works well.
Cheers for a part about Django Admin. I think it's the single most annoying, hack-needing piece of Django (as Django is great itself, we should expect perfection).
We are starting our own series of Django tips, mainly related to deployment, performance and scaling - at least one tip weekly. But thanks to you I decided that first we'll write about things we use to make Django admin work with you not against you - http://www.askthepony.com/blog/.
- what this adds to just using VB itself is that they provide pre-configured, minimal environments, kept as small as possible (less than 500MB).
- pre-configured means that it includes ssh, VB extensions, sudo, assumes NAT addressing.
- it has some support for multiple vms (DB and web separate, for example).
BUT i still can't work out what environments are available for download. there must be an obvious list somewhere... :o(
http://www.vagrantbox.es/ has quite an extensive list of user-created Vagrant boxes.
Otherwise Django-Piston sadly is the way to go.
I'm looking at ModelResource as my example.
If you aren't working with a NoSQL database or a search engine, or grabbing data from an tertiary resource then the sheer complexity found in TastyPie might not be for you.
Django-Piston doesn't offer many features, but its dead simple in its usage.
def dev():
'''Run on the development (i.e. Vagrant) server.'''
env.env_name = 'development'
env.site_name = 'MYSITE'
env.process_name = 'gunicorn-MYSITE'
env.process_owner = 'gunicorn'
env.puppet_manifest = 'dev.pp'
ssh_info = local('vagrant ssh_config', capture=True).splitlines()[1:]
ssh_info = dict([l.strip().split(' ', 1) for l in ssh_info if l.strip()])
env.key_filename = ssh_info['IdentityFile']
env.hosts = ['%(User)s@%(HostName)s:%(Port)s' % ssh_info]
env.site_path = '/var/www/MYSITE/MYSITE'
env.venv_path = '/var/www/.virtualenvs/MYSITE'
env.site_url = 'http://localhost:4565'
In a nutshell: it uses `vagrant ssh_config` to get the SSH info at runtime.Settings -> Deployment
Point to your Vagrant instance IP
Settings -> Deployment -> Options
and select 'upload changed files automatically'
EDIT: sorry I lied re opst upload script, must have confused with something else
Edit: I just found out about the remote debugging feature in PyCharm which may actually do what I want:
http://blogs.jetbrains.com/pycharm/2010/12/python-remote-deb...
Thank you so much.
Topic Vagrant-Related?
------------------------------------------------------------
Vagrant Y
Why Vagrant? Y
Using Fabric to Stay Fast and... Y
Wrangling Databases with South N
Useful Fabric Tasks Y
Watching for Changes N
Using the Werkzeug Debugger with... N
Pulling Uploads N
Preventing Accidents N
Working with Third-Party Apps N
Installing Apps from Repositories N
Mirroring Repositories N
Using BCVI to Edit Files Y
Improving the Admin Interface N
Enter Grappelli N
An Ugly Hack to Show Usable Foreign... N
Using Django-Annoying N
The render_to Decorator N
The ajax_request Decorator N
Templating Tricks N
Null Checks and Fallbacks N
Manipulating Query Strings N
Satisfying Your Designer with Typogrify N
The Flat Page Trainwreck N
Editing with Vim N
Vim for Django N
Filetype Mappings N
Python Sanity Checking N
Javascript Sanity Checking and Folding N
Django Autocommands N
Conclusion N
5/32 sections are Vagrant-related. 5/32 != almost all.EDIT: My bad, there are only 31 sections total. Still, 5/31 is not almost all.
Obviously your Dev environment isn't going to be able to match every aspect of your production environment, but keeping the same platform builds across environments is something that all teams should be aiming for.
Indeed. It's not just the right approach, it's the only approach for non-trivial applications.
Sorry for being a bit snarky, but I've seen the alternatives crumble under stress way too often.
If you use something OS-specific on your dev machine you'll need to fix it at SOME point, right?
Would you detail more on puppet please? "Run Puppet to initialize the VPS."
http://stevelosh.com/blog/2010/01/moving-from-django-to-hyde...