Re: [Zope3-Users] worldcookery.browser.widget.DynamicSequenceWidget
Ulrich P. Klein wrote: How should I modify the custom widget in the recipe examples to make it work with 3.2.0 ? As it is, the program does not work from chapter 7 onward I get this on zope.app.form.browser.SimpleInputWidget at every attempt to display the widget: instance = self._widget_factory(*args) TypeError: __init__() takes exactly 4 arguments (3 given) --- browser/widget.py.orig 2004-07-10 17:59:36.0 +0200 +++ browser/widget.py 2006-03-19 18:28:16.0 +0100 @@ -1,9 +1,9 @@ from zope.app import zapi from zope.app.form.interfaces import IInputWidget -from zope.app.form.browser.widget import SimpleInputWidget +from zope.app.form.browser.sequencewidget import SequenceWidget from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile -class DynamicSequenceWidget(SimpleInputWidget): +class DynamicSequenceWidget(SequenceWidget): Widget for (simple) sequences that does not require the form to be reloaded for every change. Close, but it still doesn't work. The widget is displayed and works on the client, but I am unable to insert ingredients. Every time I click 'add' on the form, the ingredients list comes back empty and the recipe is refused (an error occured; there are 1 input errors). I'm using Firefox 1.5 I'm attaching the list of changes I've applied to the book example (chapter 17). Basically, the one above + the alternateViews and pdf ones. diff -ruN worldcookery.orig/17sites/browser/configure.zcml worldcookery/browser/configure.zcml --- worldcookery.orig/17sites/browser/configure.zcml2004-10-04 10:14:03.0 +0200 +++ worldcookery/browser/configure.zcml 2006-03-21 11:05:59.0 +0100 @@ -102,7 +102,7 @@ permission=zope.ManageContent fields=kitchen_tools -widget field=kitchen_tools class=.widget.DynamicSequenceWidget / + widget field=kitchen_tools class=.widget.DynamicSequenceWidget / /browser:editform include package=.skin / diff -ruN worldcookery.orig/17sites/browser/recipe.py worldcookery/browser/recipe.py --- worldcookery.orig/17sites/browser/recipe.py 2006-03-21 11:39:15.0 +0100 +++ worldcookery/browser/recipe.py 2006-03-21 11:38:43.0 +0100 @@ -10,10 +10,13 @@ view = zapi.getView(plaintext, '', self.request) return view.render() -def alternateViews(self): -menu_service = zapi.getService(servicenames.BrowserMenu) -menu_id = 'alternate_views' -return menu_service.getMenu(menu_id, self.context, self.request) +#def alternateViews(self): +# menu_id = 'alternate_views' +# return getMenu(menu_id, self.context, self.request) + +#menu_service = zapi.getService(servicenames.BrowserMenu) +#menu_id = 'alternate_views' +#return menu_service.getMenu(menu_id, self.context, self.request) def rating(self): return IRating(self.context) diff -ruN worldcookery.orig/17sites/browser/recipeview.pt worldcookery/browser/recipeview.pt --- worldcookery.orig/17sites/browser/recipeview.pt 2004-09-11 15:20:44.0 +0200 +++ worldcookery/browser/recipeview.pt 2006-02-24 01:25:26.0 +0100 @@ -83,7 +83,7 @@ h4 i18n:translate=Also viewable as:/h4 ul -li tal:repeat=item view/alternateViews +li tal:repeat=item context/@@view_get_menu/alternate_views a href= tal:attributes=href string:${context/@@absolute_url}/${item/action} tal:content=item/titlealternate view/a diff -ruN worldcookery.orig/17sites/browser/widget.py worldcookery/browser/widget.py --- worldcookery.orig/17sites/browser/widget.py 2004-07-10 17:59:36.0 +0200 +++ worldcookery/browser/widget.py 2006-03-21 11:39:53.0 +0100 @@ -1,9 +1,9 @@ from zope.app import zapi from zope.app.form.interfaces import IInputWidget -from zope.app.form.browser.widget import SimpleInputWidget +from zope.app.form.browser.sequencewidget import SequenceWidget from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile -class DynamicSequenceWidget(SimpleInputWidget): +class DynamicSequenceWidget(SequenceWidget): Widget for (simple) sequences that does not require the form to be reloaded for every change. diff -ruN worldcookery.orig/17sites/pdf/browser.py worldcookery/pdf/browser.py --- worldcookery.orig/17sites/pdf/browser.py2006-03-21 11:40:52.0 +0100 +++ worldcookery/pdf/browser.py 2006-03-21 11:40:29.0 +0100 @@ -14,4 +14,4 @@ 'attachment; filename=%s' % filename) response.setHeader('Content-Type', 'application/pdf') response.setHeader('Content-Length', len(pdf.data)) -response.write(pdf.data) +return pdf.data ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Vocabularies and Zope3-svn
On Tuesday 21 March 2006 07:34, Frank Burkhardt wrote: I tried some hours modifying the RedirectTargetTypes class with implements and classProvides but it didn't work. How am I supposed to write a simple vocabulary the new way? classProvides(zope.app.schema.interfaces.IVocabularyFactory) inside your factory class works. I have this myself yesterday. Will it be 100% compatible to old style vocabularies (e.g. run on Zope 3.2)? If you want it to have 3.2 compatibility, don't change anything and ignore the deprecation warning. Once you switch you give up BBB to 3.2, but that's how deprecations work. Regards, Stephan -- Stephan Richter CBU Physics Chemistry (B.S.) / Tufts Physics (Ph.D. student) Web2k - Web Software Design, Development and Training ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Choice field missing too ? Was: [Zope3-Users] question: can I make a view trusted: A BUG
Hi, there is already a collector entry for the bug below, but I think the ChoiceField has the same issue. I too encountered a ForbiddenAttribute while accessing the title attribute of a ChoiceField. Adding the code below to fields.zcml with the corresponding changes did the trick. The error went away. I added to zope.app.schema.fields.zcml: content class=zope.schema.Choice factory id=zope.schema.Choice title=Choice Field description=Choice Field / require like_class=zope.schema.Field / - Andreas Ok everyone: it is a zope bug. The following should be included in zope.app.schema.fields.zcml: content class=zope.schema.Date factory id=zope.schema.Date title=Date Field description=Date Field / require like_class=zope.schema.Orderable / require like_class=zope.schema.Field / /content ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Vocabularies and Zope3-svn
Hi, I've got some simple vocabularies like this one: [vocabularies.py] class RedirectTargetTypes(SimpleVocabulary): def __init__(self,context): targettypes={ 'generic url':_(uArbitrary URL), 'local uid':_(uLocal UID or Permalink), 'local url':_(uLocal URL reference) } terms=[SimpleTerm(code,title=title) for (code,title) in targettypes.items()] SimpleVocabulary.__init__(self,terms) [configure.zcml] vocabulary factory=.redirect.vocabularies.RedirectTargetTypes name=Redirect targets / After the latest svn-update, I always get this warning: /var/lib/zope3/instance/mpgsite-test/lib/python/redirect/configure.zcml:26: DeprecationWarning: The 'vocabulary' directive has been deprecated and will be removed in Zope 3.5. Use the 'utility' directive instead to register the class as a named utility: utility provides=zope.app.schema.interfaces.IVocabularyFactory component=redirect.vocabularies.RedirectTargetTypes name=Redirect targets / vocabulary Unfortunately, when replacing the old 'vocabulary' by the new 'utility' directive, I get this error: File /opt/zope3-svn/zope3/src/zope/component/site.py, line 241, in provideUtility raise Invalid(The registered component doesn't provide zope.configuration.config.ConfigurationExecutionError: zope.component.interfaces.Invalid: The registered component doesn't provide the promised interface. in: File /var/lib/zope3/instance/mpgsite-test/lib/python/redirect/configure.zcml, line 26.1-30.3 utility component=.redirect.vocabularies.RedirectTargetTypes provides=zope.app.schema.interfaces.IVocabularyFactory name=Redirect targets / I tried some hours modifying the RedirectTargetTypes class with implements and classProvides but it didn't work. How am I supposed to write a simple vocabulary the new way? Will it be 100% compatible to old style vocabularies (e.g. run on Zope 3.2)? Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] worldcookery.browser.widget.DynamicSequenceWidget
On Tuesday 21 March 2006 06:14, Marco Mariani wrote: Where can I find more 'custom' widgets, in particular dynamic ones? Well, you really have to just understand the widget API, which is all located in zope.app.form and zope.app.form.browser. There are no default dynamic widgets out there, so you would have to code this from scratch. Regards, Stephan -- Stephan Richter CBU Physics Chemistry (B.S.) / Tufts Physics (Ph.D. student) Web2k - Web Software Design, Development and Training ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: Choice field missing too ? Was: [Zope3-Users] question: can I make a view trusted: A BUG
On Tuesday 21 March 2006 08:09, Andreas Elvers wrote: there is already a collector entry for the bug below, but I think the ChoiceField has the same issue. Could you make a comment on the reported bug that this is true for the choice field as well? Thanks! Regards, Stephan -- Stephan Richter CBU Physics Chemistry (B.S.) / Tufts Physics (Ph.D. student) Web2k - Web Software Design, Development and Training ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Vocabularies and Zope3-svn
Hi, On Tue, Mar 21, 2006 at 07:49:21AM -0500, Stephan Richter wrote: On Tuesday 21 March 2006 07:34, Frank Burkhardt wrote: I tried some hours modifying the RedirectTargetTypes class with implements and classProvides but it didn't work. How am I supposed to write a simple vocabulary the new way? classProvides(zope.app.schema.interfaces.IVocabularyFactory) inside your factory class works. I have this myself yesterday. My problem was not related to vocabularies but arose from a bug in zope.schema._field.Dict - which I just Collected. Thank you very much, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Problem with SetIndex (from zc.catalog)
On Mar 20, 2006, at 5:58 PM, Tom Dossis wrote: Tom Dossis wrote: Gary Poster wrote: Use the ones in zc.catalog.catalogindex.py instead: they do the necessary mixing-in for zope.app.catalog friendliness, without a patch. Looks like I missed it - thank you. The purpose of the patch was to convert documentCount workCount to methods for the advanced view. I'll try it out. Turns out I was using zc.catatlog.catalogindex.SetIndex and the patch was to convert the above attributes to methods. From memory they were showing up as repr's in the advanced catalog page. Maybe there was a way to achieve this via zcml? Just looked into this. They are not methods, they are callables: BTrees.Length.Length objects return their values when called. The indexes comply with the zope.index interfaces, and in fact are tested to do so. That said, you and Thierry are quite right that they do not display correctly in the advanced catalog view. We don't use it, so I didn't care. I just added the necessary security declarations to make this work. Unfortunately I had to reach out of the package to make a security declaration on BTrees.Length.Length.__call__; this is a bit ugly, and ideally we'd address this sometime. svn up to get the necessary changes. Gary ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Problem with SetIndex (from zc.catalog)
On Mar 20, 2006, at 6:51 PM, Thierry FLORAC wrote: On Mon, 2006-03-20 at 17:37 -0500, Gary Poster wrote: On Mar 20, 2006, at 5:14 PM, Thierry FLORAC wrote: But I'm just trying to use a simple (not subclassed) SetIndex, and then to access my catalog Advanced management page...! I don't build any specific template for this. Should I build any specific SetIndex subclass ? Or define a specific template ?? [...] Modification is OK (at first, see below) for the first indexes, but an error is raised while starting Zope for the DateTime indexes, because class attribute points to a method name : zope.configuration.config.ConfigurationExecutionError: exceptions.TypeError: type_ must be a type, class or module, not a function DateTimeValueIndex at 0xb672510c in: File /usr/local/zope/3.2/var/lib/python/zc/catalog/ configure.zcml, line 58.3-66.3 content class=.catalogindex.DateTimeValueIndex require permission=zope.ManageServices interface=zope.app.catalog.interfaces.IAttributeIndex zope.index.interfaces.IStatistics set_schema=zope.app.catalog.interfaces.IAttributeIndex / /content Ah yes, my recommendation was made too quickly. The last two should not have been there. This third stanza would do the trick. content class=.catalogindex.NormalizationWrapper require permission=zope.ManageServices interface=zope.app.catalog.interfaces.IAttributeIndex zope.index.interfaces.IStatistics set_schema=zope.app.catalog.interfaces.IAttributeIndex / /content I made this change in svn. After removing this modification for the two last indexes, I can access catalog's advanced management screen without error, but information is not really fine : on a SetIndex for example, Document Count and Word Count columns are displayed as security proxied BTrees.Length.Length instance at 0xb4dc052c instead of their numeric values... Right, then it needed a declaration for BTrees.Length.Length.__call__. This is in svn now too. Try getting rid of your changes and getting the new version from svn. It should do what you want. Gary ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] problems with contains and containers
Hi, I have a custom container and a custom content type and I want to make some simple restrictions: - Only objects that implement IMyContent can be added to objects that implement IMyContainer - Only objects that implement IMyContainer can contain objects that implement IMyContent Looks like the typical example. I implemented it following Stephan book instructions and it worked well. The only issue was that I was getting the feeling that splitting the interface in two and having something like IMyContent, IMyContentContained was a little bit ugly. Then I read about 'contains' and 'containers' and that they allowed me to keep the interfaces together because I could use strings as their arguments with the path for the other interfaces. Much nicer indeed. So here is my little demo code: from persistent import Persistent from zope.app.container.interfaces import IContainer, IContained from zope.app.container.constraints import contains, containers from zope.app.container.contained import Contained from zope.app.container.btree import BTreeContainer from zope.interface import implements class IMyContent(IContained): containers('.IMyContainer') class IMyContainer(IContainer): contains(IMyContent) class MyContent(Persistent, Contained): implements(IMyContent) class MyContainer(BTreeContainer): implements(IMyContainer) And in my browser package I have defined add views for both content types. Then I start Zope and create an instance of MyContainer in the root folder. I go into this objects and in the right hand add menu I see the only object I can add is MyContent. So far so good. The problem is when I try to get to the add form of MyContent. I get this error: 2006-03-21T18:58:13 ERROR SiteError http://localhost:8080/a/@@ +/action.html Traceback (most recent call last): File /usr/local/src/Zope-3.2.0/build/lib.linux-i686-2.4/zope/publisher/publish.py, line 138, in publish result = publication.callObject(request, object) File /usr/local/src/Zope-3.2.0/build/lib.linux-i686-2.4/zope/app/publication/zopepublication.py, line 161, in callObject return mapply(ob, request.getPositionalArguments(), request) File /usr/local/src/Zope-3.2.0/build/lib.linux-i686-2.4/zope/publisher/publish.py, line 113, in mapply return debug_call(object, args) File /usr/local/src/Zope-3.2.0/build/lib.linux-i686-2.4/zope/publisher/publish.py, line 119, in debug_call return object(*args) File /usr/local/src/Zope-3.2.0/build/lib.linux-i686-2.4/zope/app/container/browser/adding.py, line 128, in action name=view_name) is not None: File /usr/local/src/Zope-3.2.0/build/lib.linux-i686-2.4/zope/component/__init__.py, line 165, in queryMultiAdapter return sitemanager.queryMultiAdapter(objects, interface, name, default) File /usr/local/src/Zope-3.2.0/build/lib.linux-i686-2.4/zope/component/site.py, line 75, in queryMultiAdapter default) File /usr/local/src/Zope-3.2.0/build/lib.linux-i686-2.4/zope/interface/adapter.py, line 475, in queryMultiAdapter return factory(*objects) File /usr/local/src/Zope-3.2.0/build/lib.linux-i686-2.4/zope/app/form/browser/editview.py, line 64, in __init__ self._setUpWidgets() File /usr/local/src/Zope-3.2.0/build/lib.linux-i686-2.4/zope/app/form/browser/add.py, line 49, in _setUpWidgets setUpWidgets(self, self.schema, IInputWidget, names=self.fieldNames) File /home/lgs/zope/Zope-3.2/lib/python/zope/app/form/utility.py, line 153, in setUpWidgets context=context) File /home/lgs/zope/Zope-3.2/lib/python/zope/app/form/utility.py, line 97, in setUpWidget widget = _createWidget(context, field, viewType, view.request) File /home/lgs/zope/Zope-3.2/lib/python/zope/app/form/utility.py, line 65, in _createWidget return zapi.getMultiAdapter((field, request), viewType) File /usr/local/src/Zope-3.2.0/build/lib.linux-i686-2.4/zope/component/__init__.py, line 154, in getMultiAdapter raise ComponentLookupError(objects, interface, name) ComponentLookupError: ((zope.schema._bootstrapfields.Field object at 0xb52e44ec, zope.publisher.browser.BrowserRequest instance URL=http://localhost:8080/a/@@+/action.html), InterfaceClass zope.app.form.interfaces.IInputWidget, u'') And it didn't happen with my old code with splitted interfaces. Any idea? thanks in advance Lorenzo Gil ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] problems with contains and containers
Just for the record, the following implementation works: from persistent import Persistent from zope.schema import Field from zope.app.container.interfaces import IContainer, IContained from zope.app.container.constraints import contains, containers from zope.app.container.contained import Contained from zope.app.container.btree import BTreeContainer from zope.interface import implements, Interface from zope.app.container.constraints import ContainerTypesConstraint from zope.app.container.constraints import ItemTypePrecondition class IMyContent(Interface): pass class IMyContainer(IContainer): def __setitem__(name, object): pass __setitem__.precondition = ItemTypePrecondition(IMyContent) class IMyContentContained(IContained): __parent__ = Field( constraint = ContainerTypesConstraint(IMyContainer)) class MyContent(Persistent, Contained): implements(IMyContent, IMyContentContained) class MyContainer(BTreeContainer): implements(IMyContainer) El mar, 21-03-2006 a las 19:10 +0100, Lorenzo Gil Sanchez escribió: Hi, I have a custom container and a custom content type and I want to make some simple restrictions: - Only objects that implement IMyContent can be added to objects that implement IMyContainer - Only objects that implement IMyContainer can contain objects that implement IMyContent Looks like the typical example. I implemented it following Stephan book instructions and it worked well. The only issue was that I was getting the feeling that splitting the interface in two and having something like IMyContent, IMyContentContained was a little bit ugly. Then I read about 'contains' and 'containers' and that they allowed me to keep the interfaces together because I could use strings as their arguments with the path for the other interfaces. Much nicer indeed. So here is my little demo code: from persistent import Persistent from zope.app.container.interfaces import IContainer, IContained from zope.app.container.constraints import contains, containers from zope.app.container.contained import Contained from zope.app.container.btree import BTreeContainer from zope.interface import implements class IMyContent(IContained): containers('.IMyContainer') class IMyContainer(IContainer): contains(IMyContent) class MyContent(Persistent, Contained): implements(IMyContent) class MyContainer(BTreeContainer): implements(IMyContainer) And in my browser package I have defined add views for both content types. Then I start Zope and create an instance of MyContainer in the root folder. I go into this objects and in the right hand add menu I see the only object I can add is MyContent. So far so good. The problem is when I try to get to the add form of MyContent. I get this error: 2006-03-21T18:58:13 ERROR SiteError http://localhost:8080/a/@@ +/action.html Traceback (most recent call last): File /usr/local/src/Zope-3.2.0/build/lib.linux-i686-2.4/zope/publisher/publish.py, line 138, in publish result = publication.callObject(request, object) File /usr/local/src/Zope-3.2.0/build/lib.linux-i686-2.4/zope/app/publication/zopepublication.py, line 161, in callObject return mapply(ob, request.getPositionalArguments(), request) File /usr/local/src/Zope-3.2.0/build/lib.linux-i686-2.4/zope/publisher/publish.py, line 113, in mapply return debug_call(object, args) File /usr/local/src/Zope-3.2.0/build/lib.linux-i686-2.4/zope/publisher/publish.py, line 119, in debug_call return object(*args) File /usr/local/src/Zope-3.2.0/build/lib.linux-i686-2.4/zope/app/container/browser/adding.py, line 128, in action name=view_name) is not None: File /usr/local/src/Zope-3.2.0/build/lib.linux-i686-2.4/zope/component/__init__.py, line 165, in queryMultiAdapter return sitemanager.queryMultiAdapter(objects, interface, name, default) File /usr/local/src/Zope-3.2.0/build/lib.linux-i686-2.4/zope/component/site.py, line 75, in queryMultiAdapter default) File /usr/local/src/Zope-3.2.0/build/lib.linux-i686-2.4/zope/interface/adapter.py, line 475, in queryMultiAdapter return factory(*objects) File /usr/local/src/Zope-3.2.0/build/lib.linux-i686-2.4/zope/app/form/browser/editview.py, line 64, in __init__ self._setUpWidgets() File /usr/local/src/Zope-3.2.0/build/lib.linux-i686-2.4/zope/app/form/browser/add.py, line 49, in _setUpWidgets setUpWidgets(self, self.schema, IInputWidget, names=self.fieldNames) File /home/lgs/zope/Zope-3.2/lib/python/zope/app/form/utility.py, line 153, in setUpWidgets context=context) File /home/lgs/zope/Zope-3.2/lib/python/zope/app/form/utility.py, line 97, in setUpWidget widget = _createWidget(context, field, viewType, view.request) File /home/lgs/zope/Zope-3.2/lib/python/zope/app/form/utility.py, line 65, in _createWidget return zapi.getMultiAdapter((field, request), viewType) File
Re: [Zope3-Users] Announce: z3site - theme engine for Zope3-sites
Hi, I'm getting this error. I guess your product uses boston app. is this dependent on http://svn.zope.org/Zope3/branches/roger-bostonskin/ ? Sorry, i use Zope3-trunk-version. I think boston-skin include to release... For solve problem you can remove zope.app.boston.boston from browser.zcml in line 7: skin name=z3site layers=z3site rotterdam zope.app.boston.boston default/ --- to -- skin name=z3site layers=z3site rotterdam default/ (but demo-theme use boston-skin as example) ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Newbie question...
On Mon, 2006-03-20 at 19:02 -0500, Stephan Richter wrote: On Monday 20 March 2006 17:26, Thierry FLORAC wrote: Actually, the only working way I found to update my annotations through my adapters is always to use form directives with the help of a support class using getData/setData methods which call the adapter directly... Can you post the code again, the one that is not working? Note that a persistent dict is no good, since the form code tries to set an attribute and not a mapping item. You will find a copy of my previous post below. I just hope I didn't forgot anything... Thanks for any help, Thierry - 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: 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(ObjectModifiedEvent(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 uSaved changes And here is my main configure.zcml part for the adapter : adapter factory=.photo.PhotoStorage provides=.interfaces.IPhotoStorage for=.interfaces.IGalleryPhoto trusted=true / class class=.photo.PhotoStorage require permission=zope.View interface=.interfaces.IPhotoStorage / require permission=zope.ManageContent set_schema=.interfaces.IPhotoStorage / /class and finally my browser configure.zcml : form name=storage.html for=.interfaces.IGalleryPhoto schema=.interfaces.IPhotoStorage class=.forms.PhotoStorageHandler fields=identifier hostname label=Storage permission=zope.ManageContent menu=zmi_views title=Storage / A few print instructions show that : - PhotoStorageHandler.setData is called correctly, but - PhotoStorage._setIdentifier is NOT called when setting identifier property -- 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
Re: [Zope3-Users] Newbie question...
On Tuesday 21 March 2006 17:39, Thierry FLORAC wrote: class IPhotoStorage: Well, this needs to inherit Interface. class PhotoStorage: try to make this a new-style class: class PhotoStorage(object) Let me know what the outcome was. Regards, Stephan -- Stephan Richter CBU Physics Chemistry (B.S.) / Tufts Physics (Ph.D. student) Web2k - Web Software Design, Development and Training ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Newbie question...
On Tue, 2006-03-21 at 17:59 -0500, Stephan Richter wrote: On Tuesday 21 March 2006 17:39, Thierry FLORAC wrote: class IPhotoStorage: Well, this needs to inherit Interface. Of course it is ! I just forgot to put the correct syntax for this inheritance in my post... :-( class PhotoStorage: try to make this a new-style class: class PhotoStorage(object) Let me know what the outcome was. Well, hum, how could I say that ? Ho, probably just : It's amazing, but it works ! Except if I forgot something (I did so many tries to make this working...), I just rolled back to the previous release of my code, added the object superclass to my adapter, removed my form handler and switched back my ZCML configuration to the editform version of my form... Printed traces shows that everything works fine, and introspector show that my annotations are now updated correctly through my properties... Of course, I'm not sure to really understand the difference between this code and the previous one, and why this object inheritance is so important (I've always thought that every Python class was automatically inheriting from object). So any kind of explanation would be really welcome ! Many 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
Re: [Zope3-Users] Newbie question...
On Tuesday 21 March 2006 18:47, Thierry FLORAC wrote: Of course, I'm not sure to really understand the difference between this code and the previous one, and why this object inheritance is so important (I've always thought that every Python class was automatically inheriting from object). So any kind of explanation would be really welcome ! First rule: Always inherit from ``object``!!! Now the explanation. Python has the concept of old and new style classes. When inheriting ``object``, you declare a class to be a new style class. New style classes were introduced to allow for great new features, such as meta-classes, descriptors, and (for you most importantly) properties. :-) Regards, Stephan -- Stephan Richter CBU Physics Chemistry (B.S.) / Tufts Physics (Ph.D. student) Web2k - Web Software Design, Development and Training ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Problems with encoding
On Tuesday 21 March 2006 19:37, José Ernesto Guzmán Villeda wrote: hello, I'm new with zope3, I'm having some problems with the ascii encoding as soon as I get some data from a data base in order to display it in a zpt. I'm wondering if there is any configuration file to change the encoding format for my app because I manage some data in latin1 encode(using characters such as ñ). Thank you in advance. Zope 3 usually works with UTF-8. Can you describe your problem in more detail, because data form is pretty generic? Regards, Stephan -- Stephan Richter CBU Physics Chemistry (B.S.) / Tufts Physics (Ph.D. student) Web2k - Web Software Design, Development and Training ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Problems with encoding
Hi Stephan The point is that I use Latin American encoding, as I manage data in Spanish, you know we have some characters such as ñ and ´á,é,í,ó,ú. I´m getting an ascii error because whenI make a query in my data base,as some informationstored there have those characters, when I try to display that info in a zpt file, it seems that it can´t be decoded in order to be displayed in zpt. Thank you On 3/21/06, Stephan Richter [EMAIL PROTECTED] wrote: On Tuesday 21 March 2006 19:37, José Ernesto Guzmán Villeda wrote: hello, I'm new with zope3, I'm having some problems with the ascii encoding as soon as I get some data from a data base in order to display it in a zpt. I'm wondering if there is any configuration file to change the encoding format for my app because I manage some data in latin1 encode(using characters such as ñ). Thank you in advance.Zope 3 usually works with UTF-8. Can you describe your problem in more detail,because data form is pretty generic?Regards, Stephan--Stephan RichterCBU Physics Chemistry (B.S.) / Tufts Physics (Ph.D. student)Web2k - Web Software Design, Development and Training ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Problems with encoding
On Tuesday 21 March 2006 20:39, José Ernesto Guzmán Villeda wrote: The point is that I use Latin American encoding, as I manage data in Spanish, you know we have some characters such as ñ and ´á,é,í,ó,ú. I´m getting an ascii error because when I make a query in my data base, as some information stored there have those characters, when I try to display that info in a zpt file, it seems that it can´t be decoded in order to be displayed in zpt. Whenever you read data from a data source you *must* convert it to unicode. We are not guaranteeing anything when the text data is not unicode. Regards, Stephan -- Stephan Richter CBU Physics Chemistry (B.S.) / Tufts Physics (Ph.D. student) Web2k - Web Software Design, Development and Training ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] child is not cataloged while adding parent
Hi, Stephan. I'm really glad to recieve an answer from you. On Friday 03 March 2006 02:46, [EMAIL PROTECTED] wrote: and I've made an export/import view for that folder, where I succceeded to catalog children. basically both uses the same code. simply like: parent[u'the name of the child'] = Child() What I'm missing for? It'd be happy to hear anything you tell me. You are doing nothing incorrectly. The system cannot magically know about all the sub-objects to index. It is you responsibility as programmer to tell the system how to step through the children and add them to the indices. So you are on the right track! :-) I guess that you mean to notify ObjectAddedEvent. But my folderish content is a subclass of OrderedContainer. I think that __setitem__() of the OrderedContainer cares of it. and I think that's the reason of my export/import view works. isn't that right? Anyway, I tried to go through __setitem__ of the OrderedContainer. so far, I found that ObjectAddedEvent is dispatched to the IntIds in the SiteManager of the parent folder. but I don't know why. Now, I'm continueing to figure out what is happening. Any help appreciated. Regards, Katsutoshi -- Watanabe, Katsutoshi ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users