Commit 5ec1ebf1 authored by Alexandre Boeglin's avatar Alexandre Boeglin

fixed not correctly initialized variables by putting them in a _check_catalog

method and calling it from install, as when importing, build is called with
no_action=1.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6441 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 1ae6f87a
...@@ -34,6 +34,7 @@ from Products.ERP5.Document.Periodicity import Periodicity ...@@ -34,6 +34,7 @@ from Products.ERP5.Document.Periodicity import Periodicity
from Products.CMFCore.WorkflowCore import WorkflowMethod from Products.CMFCore.WorkflowCore import WorkflowMethod
from Acquisition import aq_base, aq_parent, aq_inner, aq_acquire from Acquisition import aq_base, aq_parent, aq_inner, aq_acquire
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
from Products.PageTemplates.Expressions import getEngine
from DateTime import DateTime from DateTime import DateTime
from zLOG import LOG from zLOG import LOG
...@@ -81,6 +82,17 @@ class Alarm(Periodicity, XMLObject): ...@@ -81,6 +82,17 @@ class Alarm(Periodicity, XMLObject):
""" """
return self.hasActivity() return self.hasActivity()
def callActiveSenseMethod(self, tales_expression):
"""
This resolves the active_sense_method, and calls it
"""
context = { 'here' : self.aq_parent,
'context' : self.aq_parent,
'request' : None }
compiled_tales = getEngine().compile(tales_expression)
return getEngine().getContext(context).evaluate(compiled_tales)
security.declareProtected(Permissions.ModifyPortalContent, 'activeSense') security.declareProtected(Permissions.ModifyPortalContent, 'activeSense')
def activeSense(self): def activeSense(self):
""" """
...@@ -99,8 +111,10 @@ class Alarm(Periodicity, XMLObject): ...@@ -99,8 +111,10 @@ class Alarm(Periodicity, XMLObject):
self.reindexObject() self.reindexObject()
method_id = self.getActiveSenseMethodId() method_id = self.getActiveSenseMethodId()
if method_id is not None: if method_id is not None:
method = getattr(self.activate(),method_id) return self.activate().callActiveSenseMethod(method_id)
return method() # method = getattr(self.activate(),method_id)
# return method()
s
security.declareProtected(Permissions.ModifyPortalContent, 'sense') security.declareProtected(Permissions.ModifyPortalContent, 'sense')
def sense(self): def sense(self):
......
...@@ -306,7 +306,12 @@ class Amount(Base, Variated): ...@@ -306,7 +306,12 @@ class Amount(Base, Variated):
raise KeyError, "Can not set the property variation '%s'" % \ raise KeyError, "Can not set the property variation '%s'" % \
property_id property_id
else: else:
try:
self.setProperty(property_id, property_value) self.setProperty(property_id, property_value)
except KeyError:
LOG("Amount", 200, "Can not set %s with value %s on %s" % \
(property_id, property_value, self.getRelativeUrl()))
raise
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getQuantityUnitRangeItemList') 'getQuantityUnitRangeItemList')
......
...@@ -1395,6 +1395,9 @@ class CatalogMethodTemplateItem(ObjectTemplateItem): ...@@ -1395,6 +1395,9 @@ class CatalogMethodTemplateItem(ObjectTemplateItem):
def build(self, context, **kw): def build(self, context, **kw):
ObjectTemplateItem.build(self, context, **kw) ObjectTemplateItem.build(self, context, **kw)
self._check_catalog(context)
def _check_catalog(self, context):
try: try:
catalog = context.portal_catalog.getSQLCatalog() catalog = context.portal_catalog.getSQLCatalog()
except KeyError: except KeyError:
...@@ -1471,6 +1474,7 @@ class CatalogMethodTemplateItem(ObjectTemplateItem): ...@@ -1471,6 +1474,7 @@ class CatalogMethodTemplateItem(ObjectTemplateItem):
def install(self, context, trashbin, **kw): def install(self, context, trashbin, **kw):
ObjectTemplateItem.install(self, context, trashbin, **kw) ObjectTemplateItem.install(self, context, trashbin, **kw)
self._check_catalog(context)
try: try:
catalog = context.portal_catalog.getSQLCatalog() catalog = context.portal_catalog.getSQLCatalog()
except KeyError: except KeyError:
......
...@@ -454,6 +454,8 @@ class SimulationMovement(Movement): ...@@ -454,6 +454,8 @@ class SimulationMovement(Movement):
self.getResource() != delivery.getResource() or \ self.getResource() != delivery.getResource() or \
self.getVariationCategoryList() != delivery.getVariationCategoryList()\ self.getVariationCategoryList() != delivery.getVariationCategoryList()\
or \ or \
#self.getAggregateValueList() != delivery.getAggregateValueList()\
or \
self.getAggregateList() != delivery.getAggregateList() or \ self.getAggregateList() != delivery.getAggregateList() or \
self.getStartDate() != delivery.getStartDate() or \ self.getStartDate() != delivery.getStartDate() or \
self.getStopDate() != delivery.getStopDate(): self.getStopDate() != delivery.getStopDate():
......
...@@ -329,6 +329,8 @@ class TransformedResource(Predicate, XMLObject, XMLMatrix, Amount): ...@@ -329,6 +329,8 @@ class TransformedResource(Predicate, XMLObject, XMLMatrix, Amount):
) )
tmp_amount.setVariationCategoryList(variation_category_list) tmp_amount.setVariationCategoryList(variation_category_list)
# Variation property dict # Variation property dict
tmp_amount.setVariationPropertyDict(self.getVariationPropertyDict())
prop_dict = self.getVariationPropertyDict()
tmp_amount.setVariationPropertyDict(prop_dict)
aggregated_amount_list.append(tmp_amount) aggregated_amount_list.append(tmp_amount)
return aggregated_amount_list return aggregated_amount_list
...@@ -182,7 +182,7 @@ class Person: ...@@ -182,7 +182,7 @@ class Person:
, 'storage_id' : 'default_career' , 'storage_id' : 'default_career'
, 'description' : 'The default career hold some properties of a Person.' , 'description' : 'The default career hold some properties of a Person.'
, 'type' : 'content' , 'type' : 'content'
, 'portal_type' : ( 'Career', ) , 'portal_type' : 'Career'
, 'acquired_property_id': ( 'start_date', 'stop_date', 'title', 'description' , 'acquired_property_id': ( 'start_date', 'stop_date', 'title', 'description'
, 'subordination', 'subordination_title', 'subordination_value' , 'subordination', 'subordination_title', 'subordination_value'
, 'subordination_uid_list', 'subordination_uid' , 'subordination_uid_list', 'subordination_uid'
...@@ -193,7 +193,6 @@ class Person: ...@@ -193,7 +193,6 @@ class Person:
, 'role', 'role_id', 'role_title', 'role_value' , 'role', 'role_id', 'role_title', 'role_value'
, 'function', 'function_id', 'function_title', 'function_value' , 'function', 'function_id', 'function_title', 'function_value'
) )
, 'deprecated' : 1
, 'mode' : 'w' , 'mode' : 'w'
}, },
) )
......
...@@ -103,8 +103,8 @@ class CategoryTool(CopyContainer, CMFCategoryTool, BaseTool): ...@@ -103,8 +103,8 @@ class CategoryTool(CopyContainer, CMFCategoryTool, BaseTool):
my_base_category = base_category my_base_category = base_category
bo = getattr(self, my_base_category, None) bo = getattr(self, my_base_category, None)
if bo is not None: if bo is not None:
bo_uid = int(bo.getUid()) bo_uid = bo.getUid()
uid_dict[(int(o.uid), bo_uid, 1)] = 1 # Strict membership uid_dict[(o.getUid(), bo_uid, 1)] = 1 # Strict membership
if o.meta_type == 'ERP5 Category' or o.meta_type == 'ERP5 Base Category' or \ if o.meta_type == 'ERP5 Category' or o.meta_type == 'ERP5 Base Category' or \
o.meta_type == 'CMF Category' or o.meta_type == 'CMF Base Category': o.meta_type == 'CMF Category' or o.meta_type == 'CMF Base Category':
# This goes up in the category tree # This goes up in the category tree
...@@ -113,7 +113,7 @@ class CategoryTool(CopyContainer, CMFCategoryTool, BaseTool): ...@@ -113,7 +113,7 @@ class CategoryTool(CopyContainer, CMFCategoryTool, BaseTool):
if not strict: if not strict:
while o.meta_type == 'ERP5 Category' or o.meta_type == 'CMF Category': while o.meta_type == 'ERP5 Category' or o.meta_type == 'CMF Category':
o = o.aq_parent o = o.aq_parent
uid_dict[(int(o.uid), bo_uid, 0)] = 1 # Non strict uid_dict[(o.getUid(), bo_uid, 0)] = 1 # Non strict
except (TypeError, KeyError): except (TypeError, KeyError):
LOG('WARNING: CategoriesTool',0, 'Unable to find uid for %s' % path) LOG('WARNING: CategoriesTool',0, 'Unable to find uid for %s' % path)
return uid_dict.keys() return uid_dict.keys()
......
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