如何在生产部署的 Pyramid 安装上获得 REPL?

How can I get a REPL on a production-deployed Pyramid install?

LISP 环境(Clojure 等)的一个明显优势是能够在 运行 实例上连接并获得读取评估打印循环 (REPL) - 因此能够调用生产代码并通常在运行时通过 REPL 与生产系统交互。

我目前正在使用部署在 Nginx/Phusion 乘客之上的 Python/Pyramid 堆栈 - 我发现自己多次被迫 "perform live surgery" 在数据库上,当在事实上,我更愿意调用部署的 Python 代码中存在的函数...

是否有可能为我的设置获取与生产相关的 REPL?

在此先感谢您的指点。

我认为在同一进程中没有简单的 REPL 方法,但您可能正在寻找 pshell。

pshell production.ini

您可以使用PyCharm到attach到运行Python过程:

PyCharm makes it possible to attach to a Python process, while running a Python script launched either outside of PyCharm, or inside PyCharm

另外,看看这些问题:
How do I attach a remote debugger to a Python process?
python: is it possible to attach a console into a running process

如果你想看中,试试pyramid_notebook。它为您的金字塔网站提供 IPython 笔记本 shell - 笔记本几乎是 40 年 shell 用户界面开发的结晶。设置起来比较复杂,但一旦完成,您只需单击一下即可获得交互式、安全的 shell 网络浏览器会话。

免责声明:我是该项目的作者。