[Zope3-Users] worldcookery.browser.widget.DynamicSequenceWidget

Marco Mariani marco at sferacarta.com
Tue Mar 21 05:57:53 EST 2006


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.000000000 +0200 
> +++ browser/widget.py      2006-03-19 18:28:16.000000000 +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.










-------------- next part --------------
diff -ruN worldcookery.orig/17sites/browser/configure.zcml worldcookery/browser/configure.zcml
--- worldcookery.orig/17sites/browser/configure.zcml	2004-10-04 10:14:03.000000000 +0200
+++ worldcookery/browser/configure.zcml	2006-03-21 11:05:59.000000000 +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.000000000 +0100
+++ worldcookery/browser/recipe.py	2006-03-21 11:38:43.000000000 +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.000000000 +0200
+++ worldcookery/browser/recipeview.pt	2006-02-24 01:25:26.000000000 +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/title">alternate 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.000000000 +0200
+++ worldcookery/browser/widget.py	2006-03-21 11:39:53.000000000 +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.py	2006-03-21 11:40:52.000000000 +0100
+++ worldcookery/pdf/browser.py	2006-03-21 11:40:29.000000000 +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


More information about the Zope3-users mailing list