1. 26 Aug, 2022 3 commits
    • Tatuya Kamada's avatar
      ERP5Catalog: Fix UnicodeDecodeError on non ascii catalog search when the inituser name is unicode · 0cfe6090
      Tatuya Kamada authored
      Zope4 inituser is decoded by decode('utf-8') on Zope startup and it is unicode on python2,
      therefore it raises UnicodeDecodeError when searching non ascii charater on catalog.
      
        Traceback (most recent call last):
        File "<portal_components/test.erp5.testERP5Catalog>", line 4144, in testSearchNonAsciiWithTheInitUser
          person_module.searchFolder(title=person_title)]
        File "./erp5/product/ERP5Type/Core/Folder.py", line 452, in searchFolder
          return self.portal_catalog.searchResults(**kw)
        File "./erp5/product/ERP5Catalog/CatalogTool.py", line 819, in searchResults
          return ZCatalog.searchResults(self, sql_catalog_id=catalog_id, **kw)
        File "./erp5/product/ZSQLCatalog/ZSQLCatalog.py", line 1070, in searchResults
          return catalog.searchResults(REQUEST, **kw)
        File "./erp5/product/ZSQLCatalog/SQLCatalog.py", line 2362, in searchResults
          **kw
        File "./erp5/product/ZSQLCatalog/SQLCatalog.py", line 2326, in queryResults
          **kw
        File "./erp5/product/ZSQLCatalog/SQLCatalog.py", line 2214, in buildSQLQuery
          only_group_columns,
        File "./erp5/product/ZSQLCatalog/SQLExpression.py", line 397, in asSQLExpressionDict
          'where_expression': self.getWhereExpression(),
        File "./erp5/product/ZSQLCatalog/SQLExpression.py", line 298, in getWhereExpression
          result = self.sql_expression_list[0].getWhereExpression()
        File "./erp5/product/ZSQLCatalog/SQLExpression.py", line 303, in getWhereExpression
          result = '(%s)' % (operator.join(x.getWhereExpression() for x in self.sql_expression_list), )
        UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 25: ordinal not in range(128)
      0cfe6090
    • Jérome Perrin's avatar
      xhtml_style: don't set content type header if already set · 3c8fcd51
      Jérome Perrin authored
      This is necessary on Zope4 because the error page is executed even if
      the response already has a locked body - and in this case we don't
      want to override the content-type header that might also have been set.
      
      One user of this is Base_redirect from erp5_hal_json_style, when
      abort_transaction is True, in that case it sets a body in json, a
      content type header of application/json and then raise a redirect so
      that the transaction is not commited. This fixes a problem visible on
      Zope4 with erp5_bank_reconciliation_renderjs_ui_test:testFunctionalRJSBankReconciliationAction
      3c8fcd51
    • Jérome Perrin's avatar
      hal_json_style/Base_redirect: pass an URL to Redirect · f9fe3a25
      Jérome Perrin authored
      Even if this is not used because we have locked a status earlier, the
      constructor expects an URL with zExceptions 4
      f9fe3a25
  2. 24 Aug, 2022 9 commits
  3. 23 Aug, 2022 4 commits
  4. 22 Aug, 2022 4 commits
    • Jérome Perrin's avatar
      xhtml_style: remove hashes from icons.png URLs · 1b4d4ba9
      Jérome Perrin authored
      this change was made with:
      
          find product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_ckeditor/ckeditor/ -type f  | xargs sed -i 's/\\?t=445cf24ebd//g'
      1b4d4ba9
    • Jérome Perrin's avatar
      xhtml_style: remove timestamp from ckeditor URLs · 6e8cc3c9
      Jérome Perrin authored
      This timestamp break officejs offline capabilities.
      
      This reaplies 40f6c8fe ([erp5_xhtml_style] ckeditor: drop hardcoded
      timestamp parameter in URL, 2017-10-16) on the updated CKEditor
      
      This was done with:
      
          find product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_ckeditor/ckeditor/ -type f  | xargs sed -i 's/"M6K9"/""/g'
      
      M6K9 was the timestamp for this build, that we can see at the top of
      ckeditor.js
      6e8cc3c9
    • Jérome Perrin's avatar
      c3f769b4
    • Jérome Perrin's avatar
      xhtml_style: version up ckeditor 4.19.1 · 5e82e22a
      Jérome Perrin authored
      done with an external method to upload the content of zip file in
      skin folder.
      
          import zipfile
          from io import BytesIO
      
          def uploadZip(self):
            dest = self.getPortalObject().portal_skins.custom
            with zipfile.ZipFile(
                '/srv/slapgrid/slappart3/srv/project/erp5/ckeditor_4.19.1_4b98d281bc34.zip'
            ) as f:
              for m in f.namelist():
                current_dest = dest
                print(m)
                for part in m.split('/')[:-1]:
                  if part not in current_dest.objectIds():
                    current_dest.manage_addProduct['OFSP'].manage_addFolder(id=part)
                  current_dest = current_dest[part]
                fname = m.split('/')[-1]
                if fname == '_translationstatus.txt':
                  fname = 'translationstatus.txt'
                current_dest.manage_addProduct['OFSP'].manage_addFile(
                  id=fname, file=BytesIO(f.read(m)))
            return repr(dest)
      5e82e22a
  5. 19 Aug, 2022 1 commit
  6. 18 Aug, 2022 6 commits
    • Jérome Perrin's avatar
      Listbox,SelectionTool: use make_query instead of crafting URL manually · 3cb786cc
      Jérome Perrin authored
      Using make_query makes sure that the query parameters are properly
      encoded and also change selection_index to become an int, because
      it keeps the type of parameters.
      
      As a consequence, we had to adjust a few place in the code where
      selection_index was tested for truthiness: because "0" as a string is
      true, but 0 as an int is not. For that, we changed to test the presence
      of selection_name instead of testing selection_index, as they are always
      used together.
      
      This fixes a problem that &amp; in URL was encoded twice for listbox
      anchor links ( bug_module/1137 )
      3cb786cc
    • Jérome Perrin's avatar
      *: reorganise indexation methods · 2bd1d4ed
      Jérome Perrin authored
      02011d8e (immediateReindexObject: use super user to reindex script,
      2015-12-14) did not apply for inventory, because they were overloading
      immediateReindexObject.
      Introduce a new level, _immediateReindexObject that will hold the actual
      reindexing logic.
      
      Previously this method was using PortalContent.reindexObject which was
      monkey patched, to make things less complex and more future proof, move
      the monkey patch to a method on base class.
      
      This also drops alternateReindexObject on BalanceTransaction, because it
      is already defined in Inventory
      2bd1d4ed
    • Jérome Perrin's avatar
      ERP5TypeLiveTestCase: close request at the end of each test · e605544e
      Jérome Perrin authored
      This is supposed to fix "Should not load state for ${oid of a skin} when
      the connection is closed" sometimes happening with live tests (especially
      when the test self.publish and the developer access the site while the
      test is suspended on a debugger breakpoint).
      
      The object accessed after the connection is closed was a skin (python
      script, sometimes page template or form) that was cached in SKINDATA.
      The mechanism to prune entries from the cache uses REQUEST.hold API
      which expects that REQUEST.close is called on request, but because
      requests were not closed at the end of the request, it happened that
      the cache was reused from another connection.
      
      This change to close the requests, like ERP5TypeTestCase is doing in
      tearDown (the actual close is done by Testing.ZopeTestCase.connections).
      
      By closing requests at the end of tests, we also have to change so that
      at the beginning of the test we initialize the request, by using the same
      setSite and setupCurrentSkin that are done in ERP5TypeTestCase.
      e605544e
    • Jérome Perrin's avatar
      ProxyField: use Skinnable API to get current skin · 8a8f9384
      Jérome Perrin authored
      SKINDATA is an implementation detail that should not be accessed from
      this level.
      8a8f9384
    • Jérome Perrin's avatar
      BusinessTemplate: drop useless fixZSQLMethod in SkinTemplateItem.install · 45e45842
      Jérome Perrin authored
      In SkinTemplateItem.install, self._objects contains entries for skin
      folders and for all skins. objectValues method calls was called for skin
      folders (as expected) and also for all skins, which acquire objectValues
      from skin folder and do the work again.
      
      This simplifies this by only running this for skin folders.
      45e45842
    • Jérome Perrin's avatar
      Listbox: refactor computation of "default" URL · 9ca9d73d
      Jérome Perrin authored
      "default" URL is the URL when listbox column does not use URL column
      and when the brains do not have a getListItemUrl method.
      
      Move the computation in a lazyMethod, so that it is computed only once
      per line instead of once per cell.
      
      Also remove a try/except, I don't think this code is supposed to get an
      AttributeError
      9ca9d73d
  7. 09 Aug, 2022 3 commits
  8. 02 Aug, 2022 10 commits