On Tue, 2006-03-07 at 01:20 +0100, Thierry FLORAC wrote: > My code is in fact very simple : > > class IPhotoStorage: > identifier = TextLine(...) > hostname = TextLine(...) > > PhotoStorageKey = "http://www.ulthar.net/keys/storage" > > class PhotoStorage: > implements(IPhotoStorage) > adapts(IPhoto) > > def __init__ (self, context): > self.context = self.__parent__ = context > annotations = IAnnotations(context) > data = annotations.get(PhotoStorageKey) > if data is None: > data = annotations[PhotoStorageKey] = PersistentDict() > self._data = data > > def _getIdentifier (self): > return self._data.get('identifier',None) > > def _setIdentifier (self, identifier): > self._data['identifier'] = unicode(identifier) > notify(ObjectAnnotationsModifiedEvent(self.context)) > > identifier = property(_getIdentifier, _setIdentifier) > > ...then same code for "hostname" property... > > class PhotoStorageHandler(object): > > def getData(self): > result = {} > result['identifier'] = IPhotoStorage(self.context).identifier > result['hostname'] = IPhotoStorage(self.context).hostname > return result > > def setData(self, data): > IPhotoStorage(self.context).identifier = data['identifier'] > IPhotoStorage(self.context).hostname = data['hostname'] > return u"Saved changes"
Hi, I've finally applied the following changes to my interfaces and classes, and now it works ! class IPhotoStorage: identifier = TextLine(...) def setIdentifier(): """ """ hostname = TextLine(...) def setHostname(): """ """ class PhotoStorage: implements(IPhotoStorage) adapts(IPhoto) def getIdentifier (self): return self._data.get('identifier',None) def setIdentifier (self, identifier): self._data['identifier'] = unicode(identifier) notify(ObjectModifiedEvent(self.context)) identifier = property(getIdentifier, setIdentifier) class PhotoStorageHandler(object): def getData(self): result = {} result['identifier'] = IPhotoStorage(self.context).identifier result['hostname'] = IPhotoStorage(self.context).hostname return result def setData(self, data): IPhotoStorage(self.context).setIdentifier(data['identifier']) IPhotoStorage(self.context).setHostname(data['hostname']) return u"Saved changes" So the only "real" modification I've done is to add a "setIdentifier" method to my interface, and to call this method instead of just setting the property into my form handler... Of course, this seems rather strange to me, as if the "property" setting didn't work for the adapter (but worked for the setter !). Of course, I'm not sure to understand everything... So any help, confirmation, information or any other kind of explanation would probably be very useful... Thanks, Thierry -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. _______________________________________________ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users