Saturday, October 23, 2010

Re: What does an ideal django workflow setup look like?

> I know how to get python/django working on my computer (PC or Mac) and
> have developed simple test apps using django's built-in dev server and
> a mysql back-end. So I can get things to work and don't need help on
> installing stuff.

I take all the other advice in these threads (beginning with
relentless automated tests), and I put them into fabfile.py.

Programmers should consider command lines like 'python manage.py
syncdb' and 'git push origin master' as just components of a kit. We
have no reason to type those command lines over and over again, with
minor variations each time. We should use the kit to assemble a
programmer-friendly environment.

Here's a Fabric fabfile.py example:

def sh(cmd): local(cmd, capture=False)

def _manage(command, flavor, extra=''):
sh('python manage.py %s --settings=settings.%s %s' % (command,
flavor, extra))

def test(): _manage('test', 'test' , '--verbosity=0')
def shell(): _manage('shell', 'local')

def run():
_manage('syncdb', 'local')
_manage('loaddata', 'local', 'sample_database') # CONSIDER These
data should differ from the tests.py data.
_manage('runserver', 'local')

I also move the clutter of test_settings.py, local_settings.py, etc to
a folder settings/, contain test.py, common_settings.py, local.py,
etc.

That fab file allows for short command lines:

fab run # build a sample database from your test fixtures & launch
a server

fab shell # use iPython for the best shell.

fab ci:'what I did' # run all the tests then integrate

Also, read the book "Release It!", if you think you know how to battle-
harden a website for production!

--
Phlip
http://zeekland.zeroplayer.com/

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment