[Erp5-report] r34405 luke - /erp5/trunk/products/ERP5Form/Tool/SelectionTool.py

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Apr 8 18:06:56 CEST 2010


Author: luke
Date: Thu Apr  8 18:06:54 2010
New Revision: 34405

URL: http://svn.erp5.org?rev=34405&view=rev
Log:
 - improve matching form_id with url by using regular expression

Modified:
    erp5/trunk/products/ERP5Form/Tool/SelectionTool.py

Modified: erp5/trunk/products/ERP5Form/Tool/SelectionTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Form/Tool/SelectionTool.py?rev=34405&r1=34404&r2=34405&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Form/Tool/SelectionTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5Form/Tool/SelectionTool.py [utf8] Thu Apr  8 18:06:54 2010
@@ -595,10 +595,13 @@
         # XXX-Luke: As this is not possible to do form_id -> action_id the
         # only way to know if form_id is implemented by action of document
         # is to use string matching.
-        # Current matching is not perfect - if action url is defined like:
-        #     bla/bla/[form_id]?q
-        # it will not match. re hacker will be able to improve
-        if url.endswith(form_id):
+        # This re will (form_id = Base_view):
+        # qdsqdsq/Base_view --> match
+        # qdsqdsq/Base_view?qsdsqd --> matches
+        # qdsqdsq/Base_view/qsdsqd --> matches
+        # qdsqdsq/Base_viewAaa --> doesn't match
+        # qdsqdsq/Umpa_view --> doesn't match
+        if re.search('/%s($|\W+)' % form_id, url):
           return form_id
       return 'view'
 




More information about the Erp5-report mailing list