小编dhi*_*ill的帖子

选择性地允许在Plone中使用不安全的html标签

我正在寻找一种方法将多个服务(PicasaWeb,Yahoo Pipes,Delicious书签等)的小部件放在我在Plone(目前为3.2.1)上的社区网站上.我正在寻找一种允许一组用户使用危险的html标签的方法.

我看到了一些方法,但我不知道如何实现这些方法.一个是改变编辑者拥有的页面的safe_html(1).另一种方法是在某些子树上允许这些标记(2).而另一个发现相当于"静态文本portlet"将在中间面板(3)中显示.然后我们可以使用一些复合产品(我偶然发现Collage和CMFContentPanels),将不安全的内容包含在其他网站上.

我的网站已经被广告机器人所累,所以我不想一起删除过滤.我没有一种简单(没有误报)方式来检查哪些用户是机器人,因此现在部署验证码也无济于事.

问题是:如何实施任何这些解决方案?

(我已经在没有答案的plone邮件列表上问过了,所以我想我会在这里再试一次.)

plone delicious-api

7
推荐指数
1
解决办法
223
查看次数

如何在测试运行之外使用 pytest 夹具?

我有一组装置来设置相当大的数据集。设置结果存储在数据库 ( scope=function) 中,用于报告呈现回归测试。固定装置没有参数化,所以只有一种设置,但回归测试有一些相互依赖的固定装置作为参数,无需额外查询即可访问对象。pytest 使用内存数据库并在每次测试后回滚,因此完成测试后,设置不可用。

我想在 pytest 之外使用该数据库设置进行演示和前端自动化测试。

如何在开发数据库中获取pytest夹具的结果?

一个没有细节的例子,展示夹具的结构:

@pytest.fixture
def customer():
    return mommy.make(Customer, name='Customer LTD')

@pytest.fixture(autouse=True)
def inventory_types(customer):
    return seeder.seed_inventory_types('A,B,C', customer=customer)


@pytest.fixture(autouse=True)
def inventory(
    good,
    bad,
    ugly,
    common,
    ...
):
    return

@pytest.fixture
def good(customer, patterns):
    vehicle = mommy.make(
        Inventory, 
        name='Good', 
        type=inventory_types.A, 
        customer=customer
    )

@pytest.fixture
def bad(customer, patterns):
    return make(
        Inventory, 
        name='Bad', 
        type=inventory_types.A,  
        customer=customer
    )

@pytest.fixture
def ugly(customer, patterns):
    return mommy.make(
        Inventory, 
        name='Ugly', 
        type=inventory_types.B, 
        customer=customer
    )

@pytest.fixture
def common(customer, patterns):
    return mommy.make(
        Inventory, 
        name='Common', 
        type=inventory_types.C, 
        customer=customer
    )


def …
Run Code Online (Sandbox Code Playgroud)

python database fixtures pytest

7
推荐指数
1
解决办法
2180
查看次数

定义中的 SQLite 3 类型名称和关键字是否区分大小写?

即以下声明是否等效?

CREATE TABLE example_table (
  id INTEGER PRIMARY KEY,
  name TEXT
)
Run Code Online (Sandbox Code Playgroud)

create table example_table (
  id integer primary key,
  name text
)
Run Code Online (Sandbox Code Playgroud)

我认为大写很难编辑,但我已经发现.schema交互模式下的命令会记住大小写。此外,文档始终使用大写版本。

sql sqlite case-sensitive case-insensitive

5
推荐指数
1
解决办法
194
查看次数

True == True!= Python中的False是什么意思?如何查找?

我实际上需要xor我的解决方案,但在思考它时,我开始怀疑上面的问题.是什么意思True == True != False

看一下我认为的文档True == True and True != False,但我想要一个更通用和确定的方法.如何快速获得此类代码的字节码可读形式.有没有比字节码和文档更容易找到的方法?

python bytecode operator-precedence

4
推荐指数
2
解决办法
588
查看次数

Python:如何摆脱涉及装饰器的循环依赖?

我遇到了以下循环导入的情况(这里进行了严重简化):

array2image.py转换模块:

import tuti

@tuti.log_exec_time # can't do that, evaluated at definition time
def convert(arr):
    '''Convert array to image.'''
    return image.fromarray(arr)
Run Code Online (Sandbox Code Playgroud)

tuti.py测试实用程序模块:

import array2image

def log_exec_time(f):
    '''A small decorator not using array2image'''

def debug_image(arr):
    image = array2image.convert(arr)
    image = write('somewhere')
Run Code Online (Sandbox Code Playgroud)

由于名称错误而失败。这对我来说看起来不太正确,因为那里实际上没有循环依赖。我一直在寻找一种巧妙的方法来避免这种情况或解释......在写这个问题的一半时我发现了它。

import将装饰器移至下方tuti.py可解决 NameError:

def log_exec_time(f):
    '''A small decorator not using array2image'''

import array2image

def debug_image(arr):
    image = array2image.convert(arr)
    image = write('somewhere')
Run Code Online (Sandbox Code Playgroud)

python circular-dependency decorator

3
推荐指数
1
解决办法
2453
查看次数

如何让Emacs(没有GUI)区分Ctrl + Shift + S和Ctrl + S?

我正在尝试教授Emacs标准快捷键.我使用来自Debian的emacs23-nox版本,通常是通过SSH连接.其中之一是CTRL+ SHIFT+ S另存为.配置的相关部分如下所示:

    (global-set-key (kbd "C-S") 'write-file)
    (global-set-key (kbd "C-s") 'save-buffer)

但会导致CTRL+ SHIFT+ SCTRL+ S调用'save-buffer(或者'write-file,取决于最后一行).我也试过"C-S-s"而不是"C-S".

不使用Shift键部分为什么Emacs的键盘快捷键很痛苦说不可能.我读了这个答案,但是接受的解决方案对我不起作用(Ch k CTRL+ SHIFT+ S打印Cs).

有没有办法让Emacs(没有GUI版本)区分CTRL+ SHIFT+ SCTRL+ S

emacs keyboard-shortcuts

2
推荐指数
1
解决办法
1156
查看次数