开发者

Django IDE : how to start the devserver in an editor?

开发者 https://www.devze.com 2023-02-21 12:49 出处:网络
I`m trying to develop a simple plugin for the Editra editor for django development. Right now it can create django projects and apps from within the editor. The editor is based on wxPython and I want

I`m trying to develop a simple plugin for the Editra editor for django development. Right now it can create django projects and apps from within the editor. The editor is based on wxPython and I want to start the devserver from within the editor, show a simple form with the option to stop or kill/restart the server.

The goal is to minimize the need to do repetetive tasks in the console/shell. My reason for doing this is that I am working in a Microsoft only company where you seldom do stuff using the command line. Selling django is hard when I am in and out of the shell/command line to 开发者_如何学Gostart/restart the server, syncdb, migrate etc. To make the job of selling django to my co-workers and hopefully make development easier ( at least for the django developers who likes to work in an IDE ) I have started the work on a plugin for Editra.

Right now the plugin adds a menu item called Django with two subitems; create project and create app. A context menu is in the works which will give different options depending on the content of the file being edited; right click in a window holding settings.py will give you the option to start the devserver, call syncdb, migrate if south is installed, create superuser etc. A right click in views.py will give you options to help you generate views or templates, in models.py scaffolding or generation of admin.py etc.

The only thing I cannot get my head around is how to start/kill/restart the devserver from inside the app. What I really like is to have a small window floating around with two buttons; stop or restart, which will -- stop or restart the devserver. Or a play and stop button inside the editor doing the same thing. The problem is controlling the devserver process from within the app.

If anybody has any information about this I would be very grateful. Any help, input, comments or ideas are appreciated.

Regards, Thomas Weholt


You'll want to use Python's subprocess module to launch and kill the dev server process, I imagine: http://docs.python.org/library/subprocess.html

You're probably most interested in the Popen object. With it you can launch and kill the dev server.

0

精彩评论

暂无评论...
验证码 换一张
取 消