我正在尝试为 插件 .org/" rel="nofollow">Editra 用于 django 开发的编辑器。现在它可以从编辑器中创建 django 项目和应用程序。该编辑器基于 wxPython,我想从编辑器中启动开发服务器,显示一个简单的表单,其中包含停止或终止/重新启动服务器的选项。
目标是最大限度地减少在控制台/shell 中执行重复任务的需要。我这样做的原因是我在一家只有 Microsoft 的公司工作,在那里你很少使用命令行做事。当我进出 shell/命令行来启动/重新启动服务器、syncdb、迁移等时,销售 django 是很困难的。为了使向我的同事销售 django 的工作,并希望使开发变得更容易(至少对于喜欢在 IDE 中工作的 Django 开发人员)我已经开始为 Editra 开发一个插件。
现在,该插件添加了一个名为 Django 的菜单项,其中包含两个子项;创建项目并创建应用程序。上下文菜单正在开发中,它将根据正在编辑的文件的内容提供不同的选项;右键单击持有 settings.py 的窗口,您可以选择启动开发服务器、调用syncdb、迁移(如果安装了 South)、创建超级用户等。右键单击views.py 将为您提供选项来帮助您生成视图或模板,在 models.py 脚手架或 admin.py 的生成等中。
我唯一无法理解的是如何从应用程序内部启动/终止/重新启动开发服务器。我真正喜欢的是有一个带有两个按钮的浮动小窗口;停止或重新启动,这将停止或重新启动开发服务器。或者编辑器内的播放和停止按钮执行相同的操作。问题是从应用程序内部控制开发服务器进程。
如果有人有任何这方面的信息,我将非常感激。如有任何帮助、意见、评论或想法,我们将不胜感激。
问候,
托马斯·韦霍尔特
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 start/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
发布评论
评论(1)
我想你会想要使用Python的子进程模块来启动和终止开发服务器进程: http: //docs.python.org/library/subprocess.html
您可能对 Popen 对象最感兴趣。有了它,您可以启动和终止开发服务器。
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.