Hi Everybody,

I have an adapter Person to Object. Some code:

class Object:
    def __init__(self):
        self.attributes = {}

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

    def getName(self, type):
        return self.context.attributes[type]

    def setName(self, type, value):
        self.context.attributes[type] = value

def nameProperty(type):
    fget = lambda self: self.getName(type)
    fset = lambda self, value: self.setName(type, value)
    return property(fget, fset)

class Person(NamedObject):

    firstname = nameProperty('firstname')

When I try in a view on an Object adapted to Person, the following:

self.context.firstname = 'Marc'

the name will *not* be set and I get no single error. When I call

self.context.setName('firstname', 'Marc')

the name will be set.

The getter (x=self.context.firstname) is functioning without any problems.

It looks like property can not be used as setter in views/adapters. Is that the problem? Or is there an other problem?

Zope3-users mailing list

Reply via email to