Commit 66f30ebb authored by Arnaud Fontaine's avatar Arnaud Fontaine
Browse files

ZODB Components: Preparation of erp5_base migration from FS: One Mixin per source file.

Like Document and Interface Components for the same reasons (694c9fee).
parent dc02bfa8
from Products.ERP5.Document.DeliverySimulationRule import DeliverySimulationRule
from Products.ERP5.mixin.rule import MovementGeneratorMixin
from Products.ERP5.mixin.movement_generator import MovementGeneratorMixin
class ProductionSimulationRule(DeliverySimulationRule):
"""
......
......@@ -31,7 +31,7 @@ from AccessControl import ClassSecurityInfo
from Acquisition import aq_base
from OFS.Traversable import NotFound
from Products.ERP5.mixin.extensible_traversable import DocumentExtensibleTraversableMixin
from Products.ERP5.mixin.document_extensible_traversable import DocumentExtensibleTraversableMixin
from Products.ERP5.Document.WebSection import WebSection
from Products.ERP5Type import Permissions
......
......@@ -29,7 +29,7 @@
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions
from Products.ERP5.mixin.solver import ConfigurablePropertySolverMixin
from Products.ERP5.mixin.configurable_property_solver import ConfigurablePropertySolverMixin
class AcceptSolver(ConfigurablePropertySolverMixin):
"""Target solver that accepts the values from the decision on the prevision.
......
......@@ -29,7 +29,7 @@
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions
from Products.ERP5.mixin.solver import ConfigurablePropertySolverMixin
from Products.ERP5.mixin.configurable_property_solver import ConfigurablePropertySolverMixin
class AdoptSolver(ConfigurablePropertySolverMixin):
"""Target solver that adopts the values from the prevision on the decision.
......
......@@ -41,7 +41,7 @@ from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5.Document.ImmobilisationDelivery import ImmobilisationDelivery
from Products.ERP5.mixin.amount_generator import AmountGeneratorMixin
from Products.ERP5.mixin.composition import CompositionMixin
from Products.ERP5.mixin.rule import SimulableMixin
from Products.ERP5.mixin.simulable import SimulableMixin
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod, \
unrestricted_apply
from zLOG import LOG, PROBLEM
......
......@@ -29,7 +29,8 @@
import zope.interface
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, interfaces
from Products.ERP5.mixin.rule import RuleMixin, MovementGeneratorMixin
from Products.ERP5.mixin.rule import RuleMixin
from Products.ERP5.mixin.movement_generator import MovementGeneratorMixin
from Products.ERP5.mixin.movement_collection_updater import \
MovementCollectionUpdaterMixin
......
......@@ -29,7 +29,8 @@
import zope.interface
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, interfaces
from Products.ERP5.mixin.rule import RuleMixin, MovementGeneratorMixin
from Products.ERP5.mixin.rule import RuleMixin
from Products.ERP5.mixin.movement_generator import MovementGeneratorMixin
from Products.ERP5.mixin.movement_collection_updater import \
MovementCollectionUpdaterMixin
......
......@@ -206,7 +206,7 @@ class DocumentConversionServerProxy():
def __getattr__(self, attr):
return partial(self._proxy_function, attr)
from Products.ERP5.mixin.extensible_traversable import DocumentExtensibleTraversableMixin
from Products.ERP5.mixin.document_extensible_traversable import DocumentExtensibleTraversableMixin
class Document(DocumentExtensibleTraversableMixin, XMLObject, UrlMixin,
CachedConvertableMixin, CrawlableMixin, TextConvertableMixin,
......
......@@ -29,7 +29,8 @@
import zope.interface
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, interfaces
from Products.ERP5.mixin.rule import RuleMixin, MovementGeneratorMixin
from Products.ERP5.mixin.rule import RuleMixin
from Products.ERP5.mixin.movement_generator import MovementGeneratorMixin
from Products.ERP5.mixin.movement_collection_updater import \
MovementCollectionUpdaterMixin
......
......@@ -29,7 +29,8 @@
import zope.interface
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, interfaces
from Products.ERP5.mixin.rule import RuleMixin, MovementGeneratorMixin
from Products.ERP5.mixin.rule import RuleMixin
from Products.ERP5.mixin.movement_generator import MovementGeneratorMixin
from Products.ERP5.mixin.movement_collection_updater import \
MovementCollectionUpdaterMixin
from Products.ERP5.Document.PredicateMatrix import PredicateMatrix
......
......@@ -29,7 +29,8 @@
import zope.interface
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, interfaces
from Products.ERP5.mixin.rule import RuleMixin, MovementGeneratorMixin
from Products.ERP5.mixin.rule import RuleMixin
from Products.ERP5.mixin.movement_generator import MovementGeneratorMixin
from Products.ERP5.mixin.movement_collection_updater import \
MovementCollectionUpdaterMixin
......
......@@ -29,7 +29,8 @@
import zope.interface
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, interfaces
from Products.ERP5.mixin.rule import RuleMixin, MovementGeneratorMixin
from Products.ERP5.mixin.rule import RuleMixin
from Products.ERP5.mixin.movement_generator import MovementGeneratorMixin
from Products.ERP5.mixin.movement_collection_updater import \
MovementCollectionUpdaterMixin
......
......@@ -33,7 +33,8 @@ from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, interfaces
from Products.ERP5.Document.Item import Item
from Products.ERP5.mixin.composition import CompositionMixin
from Products.ERP5.mixin.rule import MovementGeneratorMixin, SimulableMixin
from Products.ERP5.mixin.simulable import SimulableMixin
from Products.ERP5.mixin.movement_generator import MovementGeneratorMixin
from Products.ERP5.mixin.periodicity import PeriodicityMixin
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
from Products.ERP5Type.Base import Base
......
......@@ -30,7 +30,8 @@ import zope.interface
from AccessControl import ClassSecurityInfo
from Acquisition import aq_base
from Products.ERP5Type import Permissions, PropertySheet, interfaces
from Products.ERP5.mixin.rule import RuleMixin, MovementGeneratorMixin
from Products.ERP5.mixin.rule import RuleMixin
from Products.ERP5.mixin.movement_generator import MovementGeneratorMixin
from Products.ERP5.mixin.movement_collection_updater import \
MovementCollectionUpdaterMixin
......
......@@ -31,7 +31,8 @@ from AccessControl import ClassSecurityInfo
from Acquisition import aq_base
from Products.ERP5Type import Permissions, PropertySheet, interfaces
from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
from Products.ERP5.mixin.rule import RuleMixin, MovementGeneratorMixin
from Products.ERP5.mixin.rule import RuleMixin
from Products.ERP5.mixin.movement_generator import MovementGeneratorMixin
from Products.ERP5.mixin.movement_collection_updater import \
MovementCollectionUpdaterMixin
......
......@@ -30,7 +30,8 @@ import zope.interface
from AccessControl import ClassSecurityInfo
from Acquisition import aq_base
from Products.ERP5Type import Permissions, PropertySheet, interfaces
from Products.ERP5.mixin.rule import RuleMixin, MovementGeneratorMixin
from Products.ERP5.mixin.rule import RuleMixin
from Products.ERP5.mixin.movement_generator import MovementGeneratorMixin
from Products.ERP5.mixin.movement_collection_updater import \
MovementCollectionUpdaterMixin
......
......@@ -30,7 +30,7 @@
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5.Document.Domain import Domain
from Products.ERP5.mixin.extensible_traversable import DocumentExtensibleTraversableMixin
from Products.ERP5.mixin.document_extensible_traversable import DocumentExtensibleTraversableMixin
from Acquisition import aq_base, aq_inner
from Products.ERP5Type.UnrestrictedMethod import unrestricted_apply
from AccessControl import Unauthorized
......
......@@ -27,26 +27,22 @@
#
##############################################################################
from warnings import warn
from base64 import decodestring
from zLOG import LOG
from Acquisition import aq_base
from Products.ERP5Type.Globals import get_request
from AccessControl import Unauthorized
from Products.ERP5Type.ExtensibleTraversable import ExtensibleTraversableMixIn
from Products.ERP5Type.Cache import getReadOnlyTransactionCache
from AccessControl import ClassSecurityInfo, getSecurityManager
from AccessControl.SecurityManagement import newSecurityManager, setSecurityManager
from Products.CMFCore.utils import getToolByName
from Products.ERP5Type.ExtensibleTraversable import ExtensibleTraversableMixIn
from Products.ERP5Type.Cache import getReadOnlyTransactionCache
from Products.ERP5Type.Globals import InitializeClass
from Products.ERP5Type import Permissions
from Products.CMFCore.utils import getToolByName, _checkConditionalGET, _setCacheHeaders, _ViewEmulator
from OFS.Image import File as OFSFile
from warnings import warn
from base64 import decodestring
from Products.ERP5Type.UnrestrictedMethod import unrestricted_apply
from Products.ERP5.Document.Document import ConversionError, NotConvertedError
from Products.ERP5Type.Globals import get_request
# XXX: these duplicate ones in ERP5.Document
_MARKER = []
EMBEDDED_FORMAT = '_embedded'
class BaseExtensibleTraversableMixin(ExtensibleTraversableMixIn):
"""
......@@ -170,61 +166,3 @@ class BaseExtensibleTraversableMixin(ExtensibleTraversableMixIn):
return document.__of__(self)
InitializeClass(BaseExtensibleTraversableMixin)
class DocumentExtensibleTraversableMixin(BaseExtensibleTraversableMixin):
"""
This class provides a implementation of IExtensibleTraversable for Document classed based documents.
"""
def getExtensibleContent(self, request, name):
old_manager, user = self._forceIdentification(request)
# Next get the document per name
portal = self.getPortalObject()
document = self.getDocumentValue(name=name, portal=portal)
# restore original security context if there's a logged in user
if user is not None:
setSecurityManager(old_manager)
if document is not None:
document = aq_base(document.asContext(id=name, # Hide some properties to permit locating the original
original_container=document.getParentValue(),
original_id=document.getId(),
editable_absolute_url=document.absolute_url()))
return document.__of__(self)
# no document found for current user, still such document may exists
# in some cases user (like Anonymous) can not view document according to portal catalog
# but we may ask him to login if such a document exists
isAuthorizationForced = getattr(self, 'isAuthorizationForced', None)
if isAuthorizationForced is not None and isAuthorizationForced():
if unrestricted_apply(self.getDocumentValue, (name, portal)) is not None:
# force user to login as specified in Web Section
raise Unauthorized
class OOoDocumentExtensibleTraversableMixin(BaseExtensibleTraversableMixin):
"""
This class provides a implementation of IExtensibleTraversable for OOoDocument classed based documents.
"""
def getExtensibleContent(self, request, name):
# Be sure that html conversion is done,
# as it is required to extract extensible content
old_manager, user = self._forceIdentification(request)
web_cache_kw = {'name': name,
'format': EMBEDDED_FORMAT}
try:
self._convert(format='html')
view = _ViewEmulator().__of__(self)
# If we have a conditional get, set status 304 and return
# no content
if _checkConditionalGET(view, web_cache_kw):
return ''
# call caching policy manager.
_setCacheHeaders(view, web_cache_kw)
mime, data = self.getConversion(format=EMBEDDED_FORMAT, filename=name)
document = OFSFile(name, name, data, content_type=mime).__of__(self.aq_parent)
except (NotConvertedError, ConversionError, KeyError):
document = DocumentExtensibleTraversableMixin.getExtensibleContent(self, request, name)
# restore original security context if there's a logged in user
if user is not None:
setSecurityManager(old_manager)
return document
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
##############################################################################
import zope.interface
from AccessControl import ClassSecurityInfo
from Products.ERP5Type.Globals import InitializeClass
from Products.ERP5Type import Permissions, PropertySheet, interfaces
from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5.mixin.solver import SolverMixin
from Products.ERP5.mixin.configurable import ConfigurableMixin
class ConfigurablePropertySolverMixin(SolverMixin,
ConfigurableMixin,
XMLObject):
"""
Base class for Target Solvers that can be applied to many
solver-decisions of a solver process, and need to accumulate the
tested_property_list configuration among all solver-decisions
"""
add_permission = Permissions.AddPortalContent
isIndexable = 0 # We do not want to fill the catalog with objects on which we need no reporting
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
zope.interface.implements(interfaces.ISolver,
interfaces.IConfigurable,)
# Default Properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore
, PropertySheet.TargetSolver
)
def updateConfiguration(self, **kw):
# This method is called once for each 'Solver Decision' of a
# 'Solver Process' that maps into this solver for the same
# Simulation Movement, so we need to take care not to lose
# information by overwriting.
configuration = self._getConfigurationPropertyDict()
tested_property_list = configuration.get('tested_property_list')
if tested_property_list is not None:
tested_property_set = set(tested_property_list)
tested_property_set.update(kw.get('tested_property_list', ()))
kw['tested_property_list'] = list(tested_property_set)
super(ConfigurablePropertySolverMixin, self).updateConfiguration(**kw)
def getTestedPropertyList(self):
configuration_dict = self.getConfigurationPropertyDict()
tested_property_list = configuration_dict.get('tested_property_list')
if tested_property_list is None:
portal_type = self.getPortalObject().portal_types.getTypeInfo(self)
tested_property_list = portal_type.getTestedPropertyList()
return tested_property_list
InitializeClass(ConfigurablePropertySolverMixin)
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
# Ivan Tyagov <ivan@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from Acquisition import aq_base
from AccessControl import Unauthorized
from AccessControl.SecurityManagement import setSecurityManager
from Products.ERP5.mixin.base_extensible_traversable import BaseExtensibleTraversableMixin
from Products.ERP5Type.UnrestrictedMethod import unrestricted_apply
class DocumentExtensibleTraversableMixin(BaseExtensibleTraversableMixin):
"""
This class provides a implementation of IExtensibleTraversable for Document classed based documents.
"""
def getExtensibleContent(self, request, name):
old_manager, user = self._forceIdentification(request)
# Next get the document per name
portal = self.getPortalObject()
document = self.getDocumentValue(name=name, portal=portal)
# restore original security context if there's a logged in user
if user is not None:
setSecurityManager(old_manager)
if document is not None:
document = aq_base(document.asContext(id=name, # Hide some properties to permit locating the original
original_container=document.getParentValue(),
original_id=document.getId(),
editable_absolute_url=document.absolute_url()))
return document.__of__(self)
# no document found for current user, still such document may exists
# in some cases user (like Anonymous) can not view document according to portal catalog
# but we may ask him to login if such a document exists
isAuthorizationForced = getattr(self, 'isAuthorizationForced', None)
if isAuthorizationForced is not None and isAuthorizationForced():
if unrestricted_apply(self.getDocumentValue, (name, portal)) is not None:
# force user to login as specified in Web Section
raise Unauthorized
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