rvanlaar/djangorecipe — pull request #58 by anshumanb (2013-01-03 12:55:29+00:00)
Title: Enhancement: Allow initialization code to be added to control-script

I'm using [Pydev](http://pydev.org/index.html) with its Django support for my Django project. Running [Django with auto-reload](http://pydev.org/manual_adv_django.html#PyDevDjango-RunDjangowithautoreload) in Pydev requires adding a small snippet of code

import pydevd
pydevd.patch_django_autoreload(patch_remote_debugger=False, patch_show_console=True)

just before the `if _name_ == "_main_":` in the manage.py module (or in this case the control-script that is generated).

If Djangorecipe provides an `initialization` option, which would get passed as a parameter directly to `zc.buildout.easy_install.scripts`, creating a control-script for Pydev would be dead-simple. Something like the following could then be used to generate two control-scripts, one for command-line usage and one for Pydev:

...
[django]
recipe = djangorecipe
project = dummyshop
eggs = ${buildout:eggs}

[pydev]
<= django
initialization =
import pydevd
pydevd.patch_django_autoreload(patch_remote_debugger=False, patch_show_console=True)

I can submit a pull request if this enhancement gets accepted.