On Sat, 2006-03-04 at 16:01 +0100, Thierry FLORAC wrote:
> I've started to create a few components with Zope-3.2.
> Until now, everything is OK for simple content components and a few
> utilities.
> I'm actually trying to develop new adapters.
> One of these adapters is designed to use annotations, but I can't make
> it working in Zope3 management interface : page link is displayed
> correctly, in my "editform" properties provided by my interface are
> displayed and modified apparently correctly, but introspector show
> that these properties are stored as "simple" attributes and not as
> annotations ; adapter's code is never called !
> I've probably missed something, so here are the steps I followed :
> - create custom interface => OK
> - create adapter => apparently OK
> - define adapter in main "configure.zcml" file => OK
> - define "editform" in browser's "configure.zcml" => probably bad !

I've started to work a little more on this problem, and got a few
improvements but still a few "problems". In fact :
 - I can create my main content component correctly
 - I can see the adapter's "view form" into ZMI
 - I can select this view ; an empty annotations "PersistentDict" is
then immediately created as requested
 - but I can't update adapter's interface's properties : the "setData"
method is called, but the properties methods are not called when
"setData" is called. No error is displayed, and the form just display
request values that are "removed" as soon as the view is refreshed...

My code is in fact very simple :

        class IPhotoStorage:
            identifier = TextLine(...)
            hostname = TextLine(...)
        PhotoStorageKey = "http://www.ulthar.net/keys/storage";
        class PhotoStorage:
            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)
            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"

And here is my "main" configure.zcml part for the adapter :

                        trusted="true" />
                <class class=".photo.PhotoStorage">
                                interface=".interfaces.IPhotoStorage" />
                                set_schema=".interfaces.IPhotoStorage" />

and finally my "browser" configure.zcml :

                        fields="identifier hostname"
                        menu="zmi_views" title="Storage" />

Of course, a good help would be really welcome...
Many thanks,


This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Zope3-users mailing list

Reply via email to