问题标签 [pylons]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
python - Django 和 Pylons 的中间件
在我看来,Django 和 Pylons 对中间件应该如何工作有不同的想法。我喜欢 Pylons 遵循标准化的PEP 333,但 Django 似乎得到了更广泛的采用。是否可以编写用于两者的中间件?
涉及上述中间件的项目正在将一个名为 ESAPI 的安全工具包从 Java 移植到 Python。因为 Java 如此面向标准,所以很容易与框架无关。在 Python 中,不同的框架对 HttpRequest 对象和中间件等基本事物的工作方式有不同的想法,因此这似乎更加困难。
显然,新用户不能发布多个超链接。有关 Django 和 Pylons 中间件信息的链接,请参见下文。
python - How can I display updating output of a slow script using Pylons?
I am writing an application in Pylons that relies on the output of some system commands such as traceroute. I would like to display the output of the command as it is generated rather than wait for it to complete and then display all at once.
I found how to access the output of the command in Python with the answer to this question:
How can I perform a ping or traceroute in python, accessing the output as it is produced?
Now I need to find a way to get this information to the browser as it is being generated. I was planning on using jQuery's loadContent() to load the output of a script into a . The problem is that Pylons controllers use return
so the output has to be complete before Pylons renders the page and the web server responds to the client with the content.
Is there any way to have a page display content as it is generated within Pylons or will this have to be done with scripting outside of Pylons?
Basically, I'm trying to do something like this: http://network-tools.com/default.asp?prog=trace&host=www.bbc.co.uk
python - 如何在 Pylons 中启动后台进程?
我正在尝试编写一个允许用户启动相当长时间运行的进程(5-30 秒)的应用程序。然后它应该允许用户在进程生成时检查它的输出。只有用户的当前会话才需要输出,因此不需要长期存储任何内容。关于如何在利用 Pylons 框架的同时实现这一点,我有两个问题:
使用 Pylons 控制器启动诸如此类的后台进程的最佳方法是什么?
将后台进程的输出返回给用户的最佳方法是什么?(我应该将输出存储在数据库、会话数据等中吗?)
编辑:
问题是如果我subprocess
在控制器中使用启动命令,控制器会等待子进程完成后再继续,向用户显示一个正在加载的空白页面,直到进程完成。我希望能够在启动子流程后立即将用户重定向到状态页面,允许它自行完成。
python - FormEncode、pylons 和 mako 示例
我正在使用 mako 在 pylons 中工作,我想使用 FormEncode 为我的应用程序的几个部分创建表单和验证。我似乎找不到整个过程的任何好例子。我的问题是双重的:
技术的
- FancyValidators 和 Schemas - 它们的关系和语法
- Pylons 控制器和 mako 模板 - 如何收集、处理和验证数据
文体
- 控制器方法的最佳实践
- 简化表单的重用(例如更新与创建)
因此,如果您知道任何完整的示例,将不胜感激。我认为这将是与更多示例/教程的常见组合。
python - 如何相对于 Pylons 应用程序根进行链接?
在 Pylons 中,我有一个 mako 模板链接到/static/resource.css
. /pylons/static/resource.css
当我决定将应用程序映射到 Web 服务器上的子目录时,如何自动链接到?
python - 如何在 pylons 中制作 authkit 会话 cookie HttpOnly?
我将 authkit 模块与 Pylons 一起使用,我看到它设置的会话 cookie(恰当地命名为 authkit)未设置为 HttpOnly。
有没有一种简单的方法可以使它成为 HttpOnly?(我所说的“简单”是指不涉及破解 authkit 代码的那个。)
controls - 从用户那里获取号码的最佳方法是什么?
我想知道一小部分数字 [1..20],您建议使用哪种控件来提示用户进行选择。
我正在考虑一个 NumericUpDown 控件,但它对于 WebForm 不存在,更糟糕的是,我正在部署在 Pylons 应用程序(Python 框架)上
你觉得一个 DropDown 控件就足够了吗?从用户的角度来看,我仍然觉得 NumericUpDown 控件更加直观且易于使用。
会喜欢 SO 社区的意见,也许会就最佳实践提出建议。
非常感谢!
编辑:忘了提到我正在使用 YUI 库和 webhelpers 库,据我所知,没有与 numericupdown 具有等效功能的此类控件
python - 导入模型/库类并从控制器调用
我是 python 和 pylons 的新手,虽然在 PHP 方面有经验。
我正在尝试编写一个模型类,它将充当我对数据库(couchdb)的数据访问。我的问题很简单
我的模型看起来像这样,名为 models/BlogModel.py
我的控制器叫做 controllers/main.py
在我的索引操作中,如何访问 BlogModel 中的 getTitles() 方法?
我试过了
但我得到 TypeError: 'module' object is not callable
BlogModel.getTitles() 也会导致 AttributeError: 'module' object has no attribute 'getTitles'
这取决于我上课的方式吗?有人能告诉我最好的方法吗?
谢谢
python - 默认路由不起作用
我正在使用带有 pylons 的标准路由模块来尝试为我的网站主页设置默认路由。
我已经按照文档和此处http://routes.groovie.org/recipes.html中的说明进行操作,但是当我尝试时,http://127.0.0.1:5000/
我只是得到了“欢迎来到 Pylons”的默认页面。
我的 config/routing.py 文件看起来像这样
从 pylons 导入配置 从路由导入 Mapper
我也试过 map.connect('/', controller='main', action='index')
和(使用http://127.0.0.1:5000/homepage/
)
但根本没有任何作用。我知道它正在重新加载我的配置文件,因为我使用 paste serve --reload development.ini 来启动服务器
系统信息
python - 使用 init_model 中的模型对 Pylons 应用程序进行鼻子测试?
我有一个使用paster create -t pylons
一个控制器和匹配的功能测试创建的股票 Pylons 应用程序,使用添加paster controller
,以及一个 SQLAlchemy 表和映射的 ORM 类。SQLAlchemy 的东西是在init_model()
函数中定义的,而不是在模块范围内(并且需要在那里)。
运行python setup.py test
引发异常,因为在同一进程nose
中以某种方式导致init_model()
被调用两次,因此它试图创建一个已经存在的模型。
我可以通过在内部设置和检查全局变量来巧妙地解决这个问题init_model()
,但是(a)我不希望这样做,并且(b)动态定义模型的第三方库(例如 AuthKit)也会破坏测试,并且不能这么容易改变。
有没有办法修复nose
Pylons 的测试,或者我应该编写自己的测试脚本并直接使用unittest
,loadapp
和webtest
?这有什么可行的例子吗?