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

ERP5: Remove getVariationValue/setVariationValue

This was early design and we do not use this, we use Product
Individual Variation and Service Individual Variation instead.

These methods conflicts with category accessors generated from
`variation` base category.
parent 77d31fe3
...@@ -32,7 +32,6 @@ from collections import defaultdict ...@@ -32,7 +32,6 @@ from collections import defaultdict
from math import log from math import log
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5.mixin.variated import VariatedMixin from Products.ERP5.mixin.variated import VariatedMixin
from Products.ERP5.VariationValue import VariationValue
from Products.ERP5Type import Permissions, PropertySheet, interfaces from Products.ERP5Type import Permissions, PropertySheet, interfaces
from Products.ERP5Type.Base import Base from Products.ERP5Type.Base import Base
from Products.CMFCategory.Renderer import Renderer from Products.CMFCategory.Renderer import Renderer
...@@ -47,9 +46,6 @@ class Amount(Base, VariatedMixin): ...@@ -47,9 +46,6 @@ class Amount(Base, VariatedMixin):
A mix-in class which provides some utilities A mix-in class which provides some utilities
(variations, conversions, etc.) (variations, conversions, etc.)
Utilities include
- getVariation accesors (allows to access variations of whatever)
- -
""" """
...@@ -188,28 +184,6 @@ class Amount(Base, VariatedMixin): ...@@ -188,28 +184,6 @@ class Amount(Base, VariatedMixin):
self.getVariationBaseCategoryList(), self.getVariationBaseCategoryList(),
display_id=display_id,**kw) display_id=display_id,**kw)
security.declareProtected(Permissions.AccessContentsInformation,
'getVariationValue')
def getVariationValue(self):
"""
New Method for dicrete and countinuous variations
using a VariantValue instance
A new instance of VariationValue is created with categories
and attributes set to what they should be.
A this point, we only implement discrete variations
"""
return VariationValue(context = self)
def _setVariationValue(self, variation_value):
return variation_value.setVariationValue(self)
security.declareProtected(Permissions.ModifyPortalContent, 'setVariationValue')
def setVariationValue(self, variation_value):
self._setVariationValue(variation_value)
self.reindexObject()
security.declareProtected(Permissions.AccessContentsInformation, \ security.declareProtected(Permissions.AccessContentsInformation, \
'getVariationRangeCategoryItemList') 'getVariationRangeCategoryItemList')
def getVariationRangeCategoryItemList(self, *args, **kw): def getVariationRangeCategoryItemList(self, *args, **kw):
......
##############################################################################
#
# Copyright (c) 2002 Nexedi SARL 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 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 Products.ERP5Type import interfaces
from Products.ERP5Type.Context import Context
from Products.ERP5Type.Globals import InitializeClass
from Products.ERP5.mixin.variated import VariatedMixin
from zope.interface import implements
def newVariationValue(context=None, REQUEST=None, **kw):
# Create context object
context_obj = VariationValue(context=context, REQUEST=REQUEST, **kw)
# Wrap the context
if context is not None:
return context_obj.asContext(context = context)
else:
return context_obj
class VariationValue(Context, VariatedMixin):
"""
Embodies a variation value. Implements discrete variations.
"""
# Declarative interfaces
implements(interfaces.IVariated)
def __init__(self, context=None, REQUEST=None, **kw):
Context.__init__(self, context=context, REQUEST=REQUEST, **kw)
if hasattr(self, 'categories'):
self.categories = getattr(self,'categories')
elif hasattr(REQUEST,'categories'):
self.categories = getattr(REQUEST,'categories')
else:
self.categories = context.getVariationCategoryList()
def setVariationValue(self, context):
context.setVariationCategoryList(self.categories)
def __cmp__(self, other):
same = 0
a = getattr(self, 'categories', ())
b = getattr(other, 'categories', ())
for ka in a:
if not ka in b:
same = 1
for kb in b:
if not kb in a:
same = -1
return same
InitializeClass(VariationValue)
...@@ -53,7 +53,7 @@ class IVariated(Interface): ...@@ -53,7 +53,7 @@ class IVariated(Interface):
# The following methods are intended to access to the # The following methods are intended to access to the
# variation value of a variated object. Discrete variations # variation value of a variated object. Discrete variations
# are based on categories. General variations are encapsulated # are based on categories. General variations are encapsulated
# into VariationValue instances. # into Individual Variation instances.
# Property Variation Accessors # Property Variation Accessors
def getVariationPropertyList(): def getVariationPropertyList():
......
...@@ -370,16 +370,6 @@ class VariatedMixin: ...@@ -370,16 +370,6 @@ class VariatedMixin:
# display is on left # display is on left
return [x[1] for x in vrcil] return [x[1] for x in vrcil]
# Context related methods
security.declarePublic('newVariationValue')
def newVariationValue(self, context=None, REQUEST=None, **kw):
# PERFORMANCE ISSUE
from Products.ERP5.VariationValue import newVariationValue
if context is None:
return newVariationValue(REQUEST=REQUEST, **kw)
else:
return newVariationValue(context=context, REQUEST=REQUEST, **kw)
# Provide a string representation of variations # Provide a string representation of variations
security.declarePublic('getVariationText') security.declarePublic('getVariationText')
def getVariationText(self): def getVariationText(self):
......
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