———————
Класс Thing
———————
Интерфейс:
class IThingSchema(Interface):
name = TextLine(
title=u"name",
default=u"",
required=True)
cost = Float(
title=u"cost",
default=0.0,
required=True)
class IThing(IThingSchema):
pass
class Thing(BTreeContainer):
implements(IThing, IThingSchema)
name=u""
cost=0
<interface
interface=".interfaces.IThing"
type="zope.app.content.interfaces.IContentType"/>
<interface
interface=".interfaces.IThingSchema"
type="zope.app.content.interfaces.IContentType"/>
<class class=".thing.Thing">
<require
interface=".interfaces.IThing"
permission="zope.Public"
/>
<require
set_schema=".interfaces.IThingSchema"
permission="zope.Public"
/>
<require
interface="zope.container.interfaces.IReadContainer"
permission="zope.Public"
/>
<require
interface="zope.container.interfaces.IWriteContainer"
permission="zope.Public"
/>
</class>
Класс TBoolInfo:
———————
Интерфейс
class ITBoolInfoSchema(Interface):
name = TextLine(
title=u"",
default=u"",
required=True)
description = TextLine(
title=u"",
default=u"",
required=False)
props = Dict(
title=u"",
key_type = TextLine(title=u""),
value_type = List(title=u"", value_type = TextLine()),
required=False)
class ITBoolInfo(ITBoolInfoSchema):
def createProp(self, object):
pass
class TBoolInfo(Persistent):
implements(ITBoolInfo, ITBoolInfoSchema)
name=u""
description=u""
props={}
<interface
interface=".interfaces.ITBoolInfoSchema"
type="zope.app.content.interfaces.IContentType"/>
<interface
interface=".interfaces.ITBoolInfo"
type="zope.app.content.interfaces.IContentType"/>
<class class=".tbool.TBoolInfo">
<require
interface=".interfaces.ITBoolInfo"
permission="zope.Public"
/>
<require
set_schema=".interfaces.ITBoolInfoSchema"
permission="zope.Public"
/>
<require
interface="zope.container.interfaces.IReadContainer"
permission="zope.Public"
/>
<require
interface="zope.container.interfaces.IWriteContainer"
permission="zope.Public"
/>
</class>
def updateProps(self, lastvalue):
for pc in self.getPropcontainers(self.context.__parent__.__parent__,[]):
for prop in pc.values(): // prop - объект TBoolInfo
if prop.name == self.context.name:
if self.context.__parent__ in prop.props.get(lastvalue, []): // self.context.__parent__ - объект Thing
prop.props[lastvalue].remove(self.context.__parent__)
if prop.props.has_key(self.context.value):
prop.props[self.context.value].append(self.context.__parent__)
else:
prop.props[self.context.value] = [self.context.__parent__]
>> prop.props.append(self.context.__parent__)
ForbiddenAttribute: ('append', )
В чём проблема? =)