rvanlaar / djangorecipe

A django recipe for buildout
67 stars 44 forks source link

Enhancement: Allow initialization code to be added to control-script #58

Closed anshumanb closed 11 years ago

anshumanb commented 11 years ago

I'm using Pydev with its Django support for my Django project. Running Django with auto-reload 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.

reinout commented 11 years ago

I don't use pydev myself, but I've just asked two pydev-using colleagues about this.

ejnens commented 11 years ago

Nice! I think two control-scripts are indeed the way to go. Passing initialization is a very clean solution.

rvanlaar commented 11 years ago

I think this is a nice addition to django recipe.

Please submit the pull request. If you include passing unittest it will be accepted and released quicker.

rvanlaar commented 11 years ago

Thank you for your pull request that includes a test. This is very helpful. There is one thing I want to make sure before merging the pull request.

I'm not getting this buildout part: [pydev] =<django initialization = ...

I'm unfamilliar with the =< syntax and when I include this in my buildout the initialization code didn't end up in the bin/django script.

anshumanb commented 11 years ago

Try <= (instead of =<). This Buildout quick reference card has a section on cloning parts using <=.

rvanlaar commented 11 years ago

Ah, thanks for learning me something new.

I've merged the pull request. Before a release is done of a new djangorecipe version I want to include the initialization to the wsgi, fcgi and test scripts too.

anshumanb commented 11 years ago

You're welcome.

rvanlaar commented 11 years ago

JJmurre fixed this in #60