小编Pat*_*ney的帖子

Plone-为什么我收到WrongContainedType错误?

我有一个名为IReportSettings的接口,用于具有元组的注册表项,该元组存储使用接口IUserSetting的PersistantObjects,该接口由名为UserSetting的对象类型实现.IUserSetting和UserSetting的工厂适配器已在registerFactoryAdapter中注册.当我尝试使用UserSettings元组设置注册表项的IReportSettings时,我收到一个错误:

WrongContainedType: ([WrongContainedType([WrongType('uname', <type 'unicode'>,'user_name')],'')],'value')
Run Code Online (Sandbox Code Playgroud)

这是我的一些代码:

class PersistentObject(PersistentField, schema.Object):
    pass

class IUserSetting(Interface):
    user_name = schema.TextLine(title=u"User",
                                required=True,
                                default=u"",
                   )

    field_a= schema.List(title=u"Field A",
                      value_type=schema.Choice(vocabulary=u'my.product.vocabularies.SomeVocabulary'),
                      required=False,
                      default=None
           )

    field_b = schema.TextLine(title=u"Field B",
                              required=False,
                              default = u"",
              )
    .
    .

class UserSetting(object):
    implements(IUserSetting)

    def __init__(self, user_name=u'', field_a=None, field_b=u'', ..):
        self.user_name = user_name
        self.field_a = field_a
        if field_a=None:
            self.field_a = []
        self.field_b = field_b
        ..

registerFactoryAdapter(IUserSetting, UserSetting)

class IReportSettings
    settings = schema.Tuple(
        title=u"User settings for a Report",
        value_type=PersistentObject(
                IUserSetting,
                title=u"User Setting",
                description=u"a Report Setting"
            ), …
Run Code Online (Sandbox Code Playgroud)

python plone

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

Plone-如何在注册表中为字典类型的记录创建控制面板?

我正在尝试在我的Plone站点上创建一个控制面板加载项,用于编辑作为字典类型的注册表记录.

我的目的是将"供应商类型"存储为注册表中的字典.

我在profiles/default中的registry.xml:

<registry>
    <record interface="gpcl.assets.suppliertypes.ISupplierTypes" field="supplier_types">
        <value>
            <element key="1">Distributor</element>
            <element key="2">Manufacturer</element>
            <element key="3">Service Provider</element>
        </value>
    </record>
</registry>
Run Code Online (Sandbox Code Playgroud)

我的界面和形式:

class ISupplierTypes(form.Schema):
    """ Define settings data structure
    """

    supplier_types = schema.Dict(title=u"Types of Suppliers",
                                 key_type=schema.Int(title=u"supplier_type_id"),
                                 value_type=schema.TextLine(title=u"supplier_type_name", 
                                                            required=False),
                                 required=False,
                                )

class SupplierTypesEditForm(RegistryEditForm):
    """
    Define form logic
    """
    schema = ISupplierTypes
    label = u"Types of Suppliers"

    description = u"Please enter types of suppliers"


class SupplierTypesView(grok.View):
    """
    View class
    """

    grok.name("supplier-types")
    grok.context(ISiteRoot)

    def render(self):
        view_factor = layout.wrap_form(SupplierTypesEditForm, ControlPanelFormWrapper)
        view = view_factor(self.context, self.request)
        return view()
Run Code Online (Sandbox Code Playgroud)

我将它添加到我的profiles/default中的controlpanels.xml和portal_quickinstaller中,我安装了产品,控制面板确实显示在附加组件中并显示显示默认值的字段.不幸的是,当我尝试添加,编辑或删除时,会显示一条错误消息,指出"包含的类型错误".我认为我在创建控制面板的方法上错了. …

plone

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

Plone/IRelatedItems-我如何以编程方式设置灵巧内容类型的relatedItems?

在一个事件中,IAfterTransitionEvent,我正在尝试捕获正在发布的对象的事件,并且在发布对象时,创建了两个对象并且我想要关联.

在正在发布的对象的类型xml文件中,我添加了行为:

element value="plone.app.relationfield.behavior.IRelatedItems"
Run Code Online (Sandbox Code Playgroud)

这样我就可以得到relatedItems.

在我的活动中,我有:

@grok.subscribe(InitialContract, IAfterTransitionEvent)
def itemPublished(obj, event):
    site = api.portal.get()
    if event.status['action'] == 'publish':

        house_agreement = customCreateFunction(container...,type..)
        #I get the HouseAgreement object
        labor_contract = customCreateFunction(container....,type)
        #I get the LaborContract object
        relIDs = []
        relIDs.append(RelationValue(IUUID(house_agreement)))
        relIDs.append(RelationValue(IUUID(labor_contract)))

        obj.relatedItems = relIDs
Run Code Online (Sandbox Code Playgroud)

不幸的是,打印obj.relatedItems会给我一个空列表,当我转到View类并查看Categorization时,Related Items字段为空.我尝试使用_relatedItems而不是relatedItems,但这似乎不起作用,因为我认为它为obj创建了一个属性.我也试过使用IUUID而不是将它转换为RelationValue,但这并没有给我任何错误.

它就像它没有设置relatedItems值,但似乎接受传递的列表.

如果可能,我如何以编程方式设置relatedItems?

另外,我计划添加代码以防止对象被添加两次.

python plone

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

Plone/Zope/Z3c-什么会导致publishTraverse"找不到页面?"

我正在尝试获取z3c form.Form来填充其信息,而不是在url中创建get参数,我想使用publishTraverse.

所以这是我的代码的一部分:

my_object_view.py:

class EditMyObject(form.Form):
   fields = field.Fields(IMyObject)
   ignoreContext = False

   myObjectID = None

   def publishTraverse(self, request, name):
       print "Is this firing?"
       if self.myObjectID is None:
           self.myObjectID = name
           return self
       else:
           raise NotFound()

   def updateWidgets(self):
       super(EditMyObject,self).updateWidgets()
       #set id field's mode to hidden

   def getContent(self):

       db_utility = queryUtility(IMyObjectDBUtility, name="myObjectDBUtility")
       return db_utility.session.query(MyObject).filter(MyObject.My_Object_ID==self.myObjectID).one()

   #Button handlers for dealing with form also added

.....
from plone.z3cform.layout import wrap_form
EditMyObjectView = wrap_form(EditMyObject)    
Run Code Online (Sandbox Code Playgroud)

在我的浏览器文件夹中的configure.zcml文件中:

<configure
    xmlns="http://namespaces.zope.org/zope"
    xmlns:five="http://namespaces.zope.org/five"
    xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
    xmlns:zcml="http://namespaces.zope.org/zcml"
    xmlns:browser="http://namespaces.zope.org/browser"
    i18n_domain="my.object">

    <browser:page
        name="myobject-editform"
        for="*"
        permission="zope2.View" …
Run Code Online (Sandbox Code Playgroud)

zope plone z3c.form

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

Plone/portal_workflow - 为什么我不能通过zope管理界面向我的工作流添加状态?

我正在制作一个工作流程,从简单发布工作流作为基础开始(复制并粘贴)并将其重命名为my_personal_workflow

id为my_personal_workflow标题为我的个人工作流程

在我的州,我添加了一个名为draft的状态(title是Draft,id是draft)并将其设置为默认状态,并删除了其他状态.目前我正在尝试添加另一个id为'awaiting_his_approval'的状态,但是当我点击Add时,我收到一条消息,而不是创建状态.

We’re sorry, but there seems to be an error…

Here is the full error message:

Display traceback as text

Traceback (innermost last):

    Module ZPublisher.Publish, line 138, in publish
    Module ZPublisher.mapply, line 72, in mapply
    Module ZPublisher.Publish, line 53, in missing_name
    Module ZPublisher.HTTPResponse, line 741, in badRequestError

BadRequest: <h2>Site Error</h2> 
<p>An error was encountered while publishing this resource. </p>     
<p><strong>Invalid request</strong></p> 
The parameter, <em>ids</em>, was omitted from the request.
<p>Make sure to specify all required parameters, and try …
Run Code Online (Sandbox Code Playgroud)

zope plone plone-4.x

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

Plone/Grok - 在使用"zopeskel plone"构建的产品中,可以与plone.directives冲突吗?

我正在尝试按照Plone文档站点上的教程构建一个控制面板. http://docs.plone.org/develop/plone/functionality/controlpanel.html

但是,我开始使用(来自src文件夹)../bin/zopeskel plone my.product创建产品,而不是使用dexterity选项创建.当我询问我想要什么模式时,我确实选择了简单选项,当我询问是否要创建GS配置文件时,我确实选择了"是".

我确保在configure.zcml中包含grok

<include package="five.grok" />
Run Code Online (Sandbox Code Playgroud)

按照说明操作后,我尝试运行quickinstall来安装产品,但它给了我错误:

ImportError: No module named directives 
Run Code Online (Sandbox Code Playgroud)

引用他们教程的settings.py文件中的行

from plone.directives import form 
Run Code Online (Sandbox Code Playgroud)

我将plone.app.registry添加到setup.py文件中的install_requires位,我确保在configure.zcml文件中进行更改以包含Just for experimenting,我确实将'plone.app.dexterity'添加到了install_requires,但我仍然遇到同样的错误.

grok是否与plone.directives相冲突?如果是这样,我该如何解决这个问题,还是必须使用威慑而不是plone作为创建产品的选项?如果grok没有冲突,问题是什么?

另外,本教程似乎是为了使用灵巧来创建产品,但我不确定这是不是问题所在.

plone grok

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

Plone/Dexterity-如何获得对象工作流状态的"标题"?

我正在尝试获取对象所在的工作流状态的"标题".我确实尝试了几件事情,并继续获得工作流状态的"id".

一次让我成为身份的尝试

workflow = getToolByName(self.context,'portal_workflow')
status = workflow.getStatusOf("my_workflow", my_obj)
state = status["review_state"]
print state
Run Code Online (Sandbox Code Playgroud)

另一个尝试也给了我一个id

workflow = getToolByName(self.context,'portal_workflow')
status = workflow.getInfoFor(my_obj,'review_state')
#print type(status) returns "<type 'str'>"
print status
Run Code Online (Sandbox Code Playgroud)

另一种尝试:

state = api.content.get_state(obj=my_obj)
print state
Run Code Online (Sandbox Code Playgroud)

我怎样才能获得州的头衔?我必须要有一些简单的东西.

plone dexterity

0
推荐指数
1
解决办法
212
查看次数

标签 统计

plone ×7

python ×2

zope ×2

dexterity ×1

grok ×1

plone-4.x ×1

z3c.form ×1