Commit dbdb5ef5 authored by Jérome Perrin's avatar Jérome Perrin

Merge remote-tracking branch 'nexedi/master' into zope4py2

parents 87ccbb29 2bd1d4ed
Pipeline #23015 failed with stage
in 0 seconds
......@@ -440,16 +440,7 @@ class BalanceTransaction(AccountingTransaction, Inventory):
return factory
security.declarePrivate('alternateReindexObject')
def alternateReindexObject(self, **kw):
"""This method is called when an inventory object is included in a
group of catalogged objects.
"""
return self.immediateReindexObject(**kw)
def immediateReindexObject(self, **kw):
def _immediateReindexObject(self, **kw):
"""Reindexes the object.
This is different indexing that the default Inventory indexing, because
we want to take into account that lines in this balance transaction to
......
......@@ -2037,6 +2037,11 @@ class SkinTemplateItem(ObjectTemplateItem):
# Do not register skin which were explicitely ask not to be installed
if not force and update_dict.get(relative_url) == 'nothing':
continue
# self._objects contains the skin folder and all skins, for this
# we want to process only the skin folder
relative_url = relative_url.split('/')
if len(relative_url) != 2:
continue
folder = self.unrestrictedResolveValue(p, relative_url)
for obj in folder.objectValues(spec=('Z SQL Method', 'ERP5 SQL Method')):
fixZSQLMethod(p, obj)
......
......@@ -84,9 +84,9 @@ class Inventory(Delivery):
category_list.extend(value_list)
def immediateReindexObject(self, temp_constructor=None, **kw):
def _immediateReindexObject(self, temp_constructor=None, **kw):
"""
Rewrite reindexObject so that we can insert lines in stock table
Rewrite indexation method so that we can insert lines in stock table
which will be equal to the difference between stock values for
resource in the inventory and the one before the date of this inventory
......
......@@ -2132,6 +2132,41 @@ class ListBoxRendererLine:
"""
return self.getBrain().getUrl()
@lazyMethod
def getDefaultAbsoluteURL(self):
"""Compute the default link for this line.
"""
renderer = self.renderer
request = renderer.request
# brain.absolute_url() is slow because it invokes
# _aq_dynamic() every time to get brain.REQUEST,
# so we call request.physicalPathToURL() directly
# instead of brain.absolute_url().
try:
url = request.physicalPathToURL(
self.getBrain().getPath())
except AttributeError:
return None
params = []
selection_name = renderer.getSelectionName()
if int(request.get(
'ignore_layout',
0 if request.get('is_web_mode') else 1)):
params.append('ignore_layout:int=1')
if int(request.get('editable_mode', 0)):
params.append('editable_mode:int=1')
if selection_name:
params.extend(('selection_name=%s' % selection_name,
'selection_index=%s' % self.index,
'reset:int=1'))
if renderer.getSelectionTool().isAnonymous():
params.append('selection_key=%s' % renderer.getSelection().getAnonymousSelectionKey())
if params:
url = '%s?%s' % (url, '&'.join(params))
return url
def isSummary(self):
"""Return whether this line is a summary or not.
"""
......@@ -2339,9 +2374,6 @@ class ListBoxHTMLRendererLine(ListBoxRendererLine):
url_column_dict = dict(renderer.getUrlColumnList())
selection = renderer.getSelection()
selection_name = renderer.getSelectionName()
ignore_layout = int(request.get('ignore_layout',
0 if request.get('is_web_mode') else 1))
editable_mode = int(request.get('editable_mode', 0))
ui_domain = 'erp5_ui'
# We need a way to pass the current line object (ie. brain) to the
# field which is being displayed. Since the render_view API did not
......@@ -2404,28 +2436,7 @@ class ListBoxHTMLRendererLine(ListBoxRendererLine):
LOG('ListBox', WARNING, 'could not evaluate the url method getListItemUrl with %r' % (brain,),
error = sys.exc_info())
else:
try:
# brain.absolute_url() is slow because it invokes
# _aq_dynamic() every time to get brain.REQUEST,
# so we call request.physicalPathToURL() directly
# instead of brain.absolute_url().
url = request.physicalPathToURL(brain.getPath())
params = []
if ignore_layout:
params.append('ignore_layout:int=1')
if editable_mode:
params.append('editable_mode:int=1')
if selection_name:
params.extend(('selection_name=%s' % selection_name,
'selection_index=%s' % self.index,
'reset:int=1'))
selection_tool = self.getObject().getPortalObject().portal_selections
if selection_tool.isAnonymous():
params.append('selection_key=%s' % selection.getAnonymousSelectionKey())
if params:
url = '%s?%s' % (url, '&'.join(params))
except AttributeError:
pass
url = self.getDefaultAbsoluteURL()
if isinstance(url, six.binary_type):
url = six.text_type(url, encoding)
......
......@@ -36,7 +36,6 @@ from Acquisition import aq_base
from MethodObject import Method
from zLOG import LOG, WARNING
from Products.CMFCore.Skinnable import SKINDATA
from Products.Formulator import Widget, Validator
from Products.Formulator.Field import ZMIField
......@@ -439,11 +438,8 @@ class ProxyField(ZMIField):
# priority.
# This should return no field if the skin folder name is defined in
# form_id.
skin_info = SKINDATA.get(get_ident())
if skin_info is not None:
_, skin_selection_name, ignore, resolve = skin_info
skin_selection_name = object.getCurrentSkinName()
if skin_selection_name is not None:
selection_dict = portal_skins._getSelections()
candidate_folder_id_list = selection_dict[skin_selection_name].split(',')
......
......@@ -2936,9 +2936,12 @@ class Base(
def immediateReindexObject(self, *args, **kw):
if self.isAncestryIndexable():
with super_user():
PortalContent.reindexObject(self, *args, **kw)
self._immediateReindexObject(*args, **kw)
_reindexOnCreation = immediateReindexObject
def _immediateReindexObject(self, *args, **kw):
self.getPortalObject().portal_catalog.reindexCatalogObject(self, *args, **kw)
security.declarePublic('reindexObject')
def reindexObject(self, *args, **kw):
"""
......
......@@ -43,7 +43,6 @@ from Products.ERP5Type.patches import DynamicType
from Products.ERP5Type.patches import Expression
from Products.ERP5Type.patches import sqltest
from Products.ERP5Type.patches import sqlvar
from Products.ERP5Type.patches import CMFCatalogAware
from Products.ERP5Type.patches import ProductContext
from Products.ERP5Type.patches import PropertiedUser
if WITH_LEGACY_WORKFLOW:
......
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2002,2005 Nexedi SARL and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
# CMFCatalogAware patch for accepting arbitrary parameters.
from Products.CMFCore.CMFCatalogAware import CMFCatalogAware
from Acquisition import aq_base
from Products.CMFCore.utils import getToolByName
def reindexCatalogObject(self, idxs=[], *args, **kw):
"""
Reindex the object in the portal catalog.
If idxs is present, only those indexes are reindexed.
The metadata is always updated.
Also update the modification date of the object,
unless specific indexes were requested.
"""
if idxs == []:
# Update the modification date.
if getattr(aq_base(self), 'notifyModified', None) is not None:
self.notifyModified()
catalog = getToolByName(self, 'portal_catalog', None)
if catalog is not None :
catalog.reindexCatalogObject(self, idxs=idxs, *args, **kw)
CMFCatalogAware.reindexObject = reindexCatalogObject
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment