小编Gag*_*aro的帖子

如何更改字段集顺序?

我有一个表单模式,它继承自另一个表单模式.两者都有字段集.但是,字段集按其创建顺序放置.因此,最后一个模式中描述的字段集将是最后一个.我希望它成为第一个.有没有办法做到这一点 ?

例:

from plone.supermodel import model
from zope import schema

class FormSchema(model.Schema):
     model.fieldset(
          'test',
          label='Test',
          fields=['field1']
     )
     field1 = schema.Text(title=u'test')


class FormSchema2(FormSchema):
     # Is last but I would like to place it first
     model.fieldset(
          'test2',
          label='Test2',
          fields=['field2']
     )
     field2 = schema.Text(title=u'test2')
Run Code Online (Sandbox Code Playgroud)

plone dexterity z3c.form

6
推荐指数
1
解决办法
468
查看次数

如何更新node.js并在Travis CI的python项目中安装grunt/bower?

我需要在安装项目时使用grunt.我需要node.js> = 0.8.但Travis CI中的python VM中包含的版本是0.6.

我尝试下载最后的二进制文件并将其插入到PATH中,但我无法正确导出变量,如果我使用travis的env:参数更改它,则不会有其余的PATH.

如果我直接使用二进制文件(./node-v0.10.22-linux-x64/bin/npm install ...),它将安装它们./node-v0.10.22-linux-x64/bin/,当我想使用grunt时,它将调用bower(任务之一),但它将失败.(致命错误:无法执行git checkout e6f8a58dbce5858586564a1ba4543f122ef63225,退出代码为#128).

那么,更新node.js和安装二进制文件的最佳解决方案是什么?我需要在Travis CI中使用它们?

node.js npm travis-ci gruntjs bower

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

我可以使用WebTest添加非现有字段吗?

我正在使用WebTest测试表单.但是,某些字段是使用JS动态创建的,因此这些字段不在表单中.我尝试设置其中一个字段时出错:

>>> resp.form['new_field'] = 'value'
or
>>> resp.form.set('new_field', 'value')
or
>>> resp.form.set('new_field', 'value', index=0)
or 
>>> resp.form['new_field'].force_value('value')

*** AssertionError: No field by the name 'new_field' found

有没有办法创建一个字段?

django webtest django-webtest

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

如何动态地向接口添加属性

我需要为接口中的每个属性添加一个属性.所以我试图动态修改它来添加它们,但现在还没有取得多大成功.

假设我有以下界面:

class IMember(Interface):
    first_name = schema.TextLine(title=u'first name')
    last_name = schema.TextLine(title=u'last name')
Run Code Online (Sandbox Code Playgroud)

我想像这样修改它:

class IMember(Interface):
    first_name = schema.TextLine(title=u'first name')
    last_name = schema.TextLine(title=u'last name')
    visbility_first_name = schema.Bool(title=u'Display: first name')
    visbility_last_name = schema.Bool(title=u'Display: last name')
Run Code Online (Sandbox Code Playgroud)

我之后尝试修改了类,但由于它已经初始化,因此设置了架构,我不知道如何更改它.我还想过编写一个指令(例如:interface.Implements())但是添加属性似乎很复杂.

我的最终目标是添加一个带有一组Bool小部件的z3c.form字段集.

那么,有没有办法在Python中完成它,或者我是否必须修改界面并手动添加所有属性?

谢谢 !

python plone zope.interface

4
推荐指数
1
解决办法
348
查看次数