Commit 2a772e64 authored by Xiaowu Zhang's avatar Xiaowu Zhang

Added an API to create a default price calculation context to computer price.

parent e8334f14
...@@ -645,6 +645,16 @@ class Resource(XMLObject, XMLMatrix, VariatedMixin): ...@@ -645,6 +645,16 @@ class Resource(XMLObject, XMLMatrix, VariatedMixin):
return -1 # a defines a destination section and wins return -1 # a defines a destination section and wins
return 1 # a defines no destination section and loses return 1 # a defines no destination section and loses
def _getPriceCalculationContext(self):
# Tries to find a default context to feed the price calculation
# process. For example, it will set a context in which the
# destination_section is set to the end user the the currency
# to the preferred currency of the end user
method = self._getTypeBasedMethod('getPriceCalculationDefaultContext')
if method is not None:
return method()
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getPriceParameterDict') 'getPriceParameterDict')
def getPriceParameterDict(self, context=None, REQUEST=None, def getPriceParameterDict(self, context=None, REQUEST=None,
...@@ -747,6 +757,8 @@ class Resource(XMLObject, XMLMatrix, VariatedMixin): ...@@ -747,6 +757,8 @@ class Resource(XMLObject, XMLMatrix, VariatedMixin):
""" """
Return the unit price of a resource in a specific context. Return the unit price of a resource in a specific context.
""" """
if context is None:
context=self.Resource_getPriceCalculationDefaultContext()
# see Movement.getPrice # see Movement.getPrice
if isinstance(default, Base) and context is None: if isinstance(default, Base) and context is None:
msg = 'getPrice first argument is supposed to be the default value'\ msg = 'getPrice first argument is supposed to be the default value'\
......
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