z3c.formjs widgetselector customization

Simon Elbaz <[email protected]>
Newsgroups gmane.comp.web.zope.devel
Message-ID <[email protected]>
Hi all,
I use z3c.formjs in a project and would like to customize the selector id
used into jsaction.handler for form field.
Why ? because the z3c.formui templates add "-row" suffix to the widget id
and I need also to add the "-row" suffix to the selector id in the event
handler.

I have attached a patch for the jsaction.py file that use the default
WidgetSelector class if no IWidgetSelector component is locally registered.

If it is a good idea, how could I apply it to svn repository ?

regards,
Simon

_______________________________________________
Zope-Dev maillist  -  [email protected]
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )
jsaction.py.patch (application/octet-stream, 1.4 KB)
*** jsaction.py	2009-06-18 08:16:41.000000000 +0200
--- /home/simon/.buildout/eggs/z3c.formjs-0.5.0-py2.5.egg/z3c/formjs/jsaction.py	2011-02-14 14:03:33.000000000 +0100
***************
*** 26,31 ****
--- 26,32 ----
  from z3c.form.interfaces import IField, IFieldWidget
  from z3c.form.interfaces import IFormLayer, IFormAware
  from z3c.form.interfaces import IButtonAction, IAfterWidgetUpdateEvent
+ from zope.component import queryUtility
  
  from z3c.formjs import interfaces, jsevent
  
***************
*** 201,207 ****
      # Step 1: Get the handler.
      handlers = widget.form.jshandlers.getHandlers(widget.field)
      # Step 2: Create a selector.
!     selector = WidgetSelector(widget)
      # Step 3: Make sure that the form has JS subscriptions, otherwise add
      #         it.
      if not interfaces.IHaveJSSubscriptions.providedBy(widget.form):
--- 202,213 ----
      # Step 1: Get the handler.
      handlers = widget.form.jshandlers.getHandlers(widget.field)
      # Step 2: Create a selector.
!     selector_cls = queryUtility(interfaces.IWidgetSelector)
!     if selector_cls is None:
! 	    selector = WidgetSelector(widget)
!     else:
! 	    selector = selector_cls(widget)
! 
      # Step 3: Make sure that the form has JS subscriptions, otherwise add
      #         it.
      if not interfaces.IHaveJSSubscriptions.providedBy(widget.form):
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.