使用schemaextender扩展ATEvent类

时间:2011-09-30 03:11:02

标签: plone

我使用了schemaextender来扩展ATEvents,以便它们包含一个用于切换时间的复选框和用于事件的iCal显示。

它在现有网站上运行正常但是当我尝试创建一个新网站时,我收到一个错误“ValueError:nextPreviousEnabled.default_method既不是一种方法也不是一种可调用方式”

有什么想法吗?扩展代码:

from Products.Archetypes.public import BooleanField
from archetypes.schemaextender.field import ExtensionField

class DisplayEventTimeField(ExtensionField, BooleanField):
    """A toggle to indicate whether the view should display the time or just the date of this community event"""

from zope.component import adapts
from zope.interface import implements
from archetypes.schemaextender.interfaces import ISchemaExtender
from Products.Archetypes.public import BooleanWidget
from Products.ATContentTypes.interface import IATEvent

class EventExtender(object):
    adapts(IATEvent)
    implements(ISchemaExtender)


    fields = [
        DisplayEventTimeField("display_event_time",
        widget = BooleanWidget(
            label="Display event time",
            description="Turn this off to show only the event date (also disables iCal/vCal)",
            defult=True)),
            ]

    def __init__(self, context):
        self.context = context

    def getFields(self):
        return self.fields

和完整的追溯:

Traceback (innermost last):
  Module ZPublisher.Publish, line 127, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module Products.PDBDebugMode.runcall, line 70, in pdb_runcall
  Module ZPublisher.Publish, line 47, in call_object
  Module Products.CMFPlone.browser.admin, line 201, in __call__
  Module Products.CMFPlone.factory, line 83, in addPloneSite
  Module Products.GenericSetup.tool, line 330, in runAllImportStepsFromProfile
   - __traceback_info__: profile-Products.CMFPlone:plone-content
  Module Products.GenericSetup.tool, line 1085, in _runImportStepsFromContext
  Module Products.GenericSetup.tool, line 999, in _doRunImportStep
   - __traceback_info__: plone-content
  Module Products.CMFPlone.setuphandlers, line 486, in importContent
  Module Products.CMFPlone.setuphandlers, line 234, in setupPortalContent
  Module Products.CMFPlone.utils, line 306, in _createObjectByType
  Module Products.CMFCore.TypesTool, line 554, in _constructInstance
  Module Products.ATContentTypes.content.topic, line 6, in addATTopic
  Module Products.Archetypes.BaseFolder, line 96, in manage_afterAdd
  Module Products.Archetypes.BaseObject, line 159, in manage_afterAdd
   - __traceback_info__: (<ATTopic at /Plone/news/aggregator>, <ATTopic at /Plone/news/aggregator>, <App.ProductContext.__FactoryDispatcher__ object at 0x1071bfd50>)
  Module Products.Archetypes.BaseObject, line 174, in initializeLayers
  Module Products.Archetypes.Schema, line 338, in initializeLayers
  Module Products.Archetypes.Storage, line 161, in initializeField
  Module Products.Archetypes.Field, line 591, in getDefault
ValueError: nextPreviousEnabled.default_method is neither a method of <class 'Products.ATContentTypes.content.topic.ATTopic'> nor a callable

1 个答案:

答案 0 :(得分:1)

尝试使用browserlayer并实施IBrowserLayerAwareExtender的{​​{1}}内容:

ISchemaExtender

这样可确保仅在安装产品时扩展架构。一般来说,始终建议保持对实际plone实例的自定义隔离。