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