Commit 48c50120 authored by Jérome Perrin's avatar Jérome Perrin

getQuantityPrecisionFromResource ignores empty strings, so that you can safely

call doc.getQuantityPrecisionFromResource(doc.getResource()) even if resource
is not set on doc.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@12351 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 85abdcca
...@@ -2541,12 +2541,14 @@ class Base( CopyContainer, ...@@ -2541,12 +2541,14 @@ class Base( CopyContainer,
def getQuantityPrecisionFromResource(self, resource): def getQuantityPrecisionFromResource(self, resource):
""" """
Provides a quick access to precision without accessing the resource Provides a quick access to precision without accessing the resource
value in ZODB value in ZODB. Here resource is the relative_url of the resource, such as
the result of self.getResource().
""" """
def cached_getQuantityPrecisionFromResource(resource): def cached_getQuantityPrecisionFromResource(resource):
resource_value = self.portal_categories.resolveCategory(resource) if resource:
if resource_value is not None: resource_value = self.portal_categories.resolveCategory(resource)
return resource_value.getQuantityPrecision() if resource_value is not None:
return resource_value.getQuantityPrecision()
return 0 return 0
cached_getQuantityPrecisionFromResource = CachingMethod( cached_getQuantityPrecisionFromResource = CachingMethod(
......
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