Commit 3e4484ee authored by Kevin Deldycke's avatar Kevin Deldycke

Fix the bug which return creation_date as string instead of pure DateTime Object (thanks JPS).

Auto-delete trailing spaces.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@8680 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0af640e1
...@@ -59,6 +59,7 @@ from CopySupport import CopyContainer, CopyError,\ ...@@ -59,6 +59,7 @@ from CopySupport import CopyContainer, CopyError,\
from Errors import DeferredCatalogError from Errors import DeferredCatalogError
from Products.CMFActivity.ActiveObject import ActiveObject from Products.CMFActivity.ActiveObject import ActiveObject
from Products.ERP5Type.Accessor.Accessor import Accessor as Method from Products.ERP5Type.Accessor.Accessor import Accessor as Method
from Products.ERP5Type.Accessor.TypeDefinition import asDate
from string import join from string import join
import sys import sys
...@@ -120,7 +121,7 @@ def _aq_reset(): ...@@ -120,7 +121,7 @@ def _aq_reset():
Base.aq_method_generated = {} Base.aq_method_generated = {}
Base.aq_portal_type = {} Base.aq_portal_type = {}
Base.aq_related_generated = 0 Base.aq_related_generated = 0
Base.aq_preference_generated = 0 Base.aq_preference_generated = 0
# Some method generations are based on portal methods, and portal methods cache results. # Some method generations are based on portal methods, and portal methods cache results.
# So it is safer to invalidate the cache. # So it is safer to invalidate the cache.
...@@ -228,10 +229,10 @@ def initializePortalTypeDynamicWorkflowMethods(self, klass, prop_holder): ...@@ -228,10 +229,10 @@ def initializePortalTypeDynamicWorkflowMethods(self, klass, prop_holder):
# We should now make sure workflow methods are defined # We should now make sure workflow methods are defined
# and also make sure simulation state is defined # and also make sure simulation state is defined
portal_workflow = getToolByName(self, 'portal_workflow') portal_workflow = getToolByName(self, 'portal_workflow')
# LOG('getWorkflowsFor', 0, # LOG('getWorkflowsFor', 0,
# str((self, [wf.id for wf in portal_workflow.getWorkflowsFor(self)]))) # str((self, [wf.id for wf in portal_workflow.getWorkflowsFor(self)])))
for wf in portal_workflow.getWorkflowsFor(self): for wf in portal_workflow.getWorkflowsFor(self):
# LOG('in aq_portal_type %s' % id, 0, # LOG('in aq_portal_type %s' % id, 0,
# "found state workflow %s" % wf.id) # "found state workflow %s" % wf.id)
if wf.__class__.__name__ in ('DCWorkflowDefinition', ): if wf.__class__.__name__ in ('DCWorkflowDefinition', ):
wf_id = wf.id wf_id = wf.id
...@@ -241,16 +242,16 @@ def initializePortalTypeDynamicWorkflowMethods(self, klass, prop_holder): ...@@ -241,16 +242,16 @@ def initializePortalTypeDynamicWorkflowMethods(self, klass, prop_holder):
for method_id, getter in ( for method_id, getter in (
('get%s' % UpperCase(state_var), WorkflowState.Getter), ('get%s' % UpperCase(state_var), WorkflowState.Getter),
('get%sTitle' % UpperCase(state_var), WorkflowState.TitleGetter), ('get%sTitle' % UpperCase(state_var), WorkflowState.TitleGetter),
('getTranslated%s' % UpperCase(state_var), ('getTranslated%s' % UpperCase(state_var),
WorkflowState.TranslatedGetter), WorkflowState.TranslatedGetter),
('getTranslated%sTitle' % UpperCase(state_var), ('getTranslated%sTitle' % UpperCase(state_var),
WorkflowState.TranslatedTitleGetter)): WorkflowState.TranslatedTitleGetter)):
if not hasattr(prop_holder, method_id): if not hasattr(prop_holder, method_id):
method = getter(method_id, wf_id) method = getter(method_id, wf_id)
# Attach to portal_type # Attach to portal_type
setattr(prop_holder, method_id, method) setattr(prop_holder, method_id, method)
prop_holder.security.declareProtected( prop_holder.security.declareProtected(
Permissions.AccessContentsInformation, Permissions.AccessContentsInformation,
method_id ) method_id )
for wf in portal_workflow.getWorkflowsFor(self): for wf in portal_workflow.getWorkflowsFor(self):
wf_id = wf.id wf_id = wf.id
...@@ -266,9 +267,9 @@ def initializePortalTypeDynamicWorkflowMethods(self, klass, prop_holder): ...@@ -266,9 +267,9 @@ def initializePortalTypeDynamicWorkflowMethods(self, klass, prop_holder):
(not hasattr(klass, method_id)): (not hasattr(klass, method_id)):
method = WorkflowMethod(klass._doNothing, tr_id) method = WorkflowMethod(klass._doNothing, tr_id)
# Attach to portal_type # Attach to portal_type
setattr(prop_holder, method_id, method) setattr(prop_holder, method_id, method)
prop_holder.security.declareProtected( prop_holder.security.declareProtected(
Permissions.AccessContentsInformation, Permissions.AccessContentsInformation,
method_id ) method_id )
else: else:
# Wrap method into WorkflowMethod is needed # Wrap method into WorkflowMethod is needed
...@@ -276,13 +277,13 @@ def initializePortalTypeDynamicWorkflowMethods(self, klass, prop_holder): ...@@ -276,13 +277,13 @@ def initializePortalTypeDynamicWorkflowMethods(self, klass, prop_holder):
method = getattr(klass, method_id) method = getattr(klass, method_id)
except AttributeError: except AttributeError:
method = getattr(prop_holder, method_id) method = getattr(prop_holder, method_id)
work_method_holder = prop_holder work_method_holder = prop_holder
else: else:
work_method_holder = klass work_method_holder = klass
# Wrap method # Wrap method
if callable(method): if callable(method):
if not isinstance(method, WorkflowMethod): if not isinstance(method, WorkflowMethod):
setattr(work_method_holder, method_id, setattr(work_method_holder, method_id,
WorkflowMethod(method, method_id)) WorkflowMethod(method, method_id))
else : else :
# some methods (eg. set_ready) doesn't have the same name # some methods (eg. set_ready) doesn't have the same name
...@@ -308,7 +309,7 @@ def initializePortalTypeDynamicWorkflowMethods(self, klass, prop_holder): ...@@ -308,7 +309,7 @@ def initializePortalTypeDynamicWorkflowMethods(self, klass, prop_holder):
(not hasattr(klass,method_id)): (not hasattr(klass,method_id)):
method = WorkflowMethod(klass._doNothing, imethod_id) method = WorkflowMethod(klass._doNothing, imethod_id)
# Attach to portal_type # Attach to portal_type
setattr(prop_holder, method_id, method) setattr(prop_holder, method_id, method)
prop_holder.security.declareProtected( prop_holder.security.declareProtected(
Permissions.AccessContentsInformation, Permissions.AccessContentsInformation,
method_id) method_id)
...@@ -369,8 +370,8 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ): ...@@ -369,8 +370,8 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
aq_method_generated = {} aq_method_generated = {}
aq_portal_type = {} aq_portal_type = {}
aq_related_generated = 0 aq_related_generated = 0
aq_preference_generated = 0 aq_preference_generated = 0
# FIXME: Preference should not be included in ERP5Type # FIXME: Preference should not be included in ERP5Type
# Declarative security # Declarative security
...@@ -480,9 +481,9 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ): ...@@ -480,9 +481,9 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
if bid not in generated_bid : if bid not in generated_bid :
createRelatedValueAccessors(Base, bid) createRelatedValueAccessors(Base, bid)
generated_bid[bid] = 1 generated_bid[bid] = 1
Base.aq_related_generated = 1 Base.aq_related_generated = 1
if not Base.aq_preference_generated: if not Base.aq_preference_generated:
try : try :
from Products.ERP5Form.PreferenceTool import createPreferenceMethods from Products.ERP5Form.PreferenceTool import createPreferenceMethods
...@@ -492,7 +493,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ): ...@@ -492,7 +493,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
'unable to create methods for PreferenceTool', e) 'unable to create methods for PreferenceTool', e)
raise raise
Base.aq_preference_generated = 1 Base.aq_preference_generated = 1
# Always try to return something after generation # Always try to return something after generation
if generated: if generated:
# We suppose that if we reach this point # We suppose that if we reach this point
...@@ -990,7 +991,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ): ...@@ -990,7 +991,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
except TypeError: except TypeError:
old_value = self.getProperty(key) old_value = self.getProperty(key)
if old_value != kw[key] or force_update: if old_value != kw[key] or force_update:
# We keep in a thread var the previous values # We keep in a thread var the previous values
# this can be useful for interaction workflow to implement lookups # this can be useful for interaction workflow to implement lookups
...@@ -1090,7 +1091,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ): ...@@ -1090,7 +1091,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
sql_text = '(%s.category_uid = %s AND %s.base_category_uid = %s)' % \ sql_text = '(%s.category_uid = %s AND %s.base_category_uid = %s)' % \
(table, self.getUid(), table, base_category.getBaseCategoryUid()) (table, self.getUid(), table, base_category.getBaseCategoryUid())
return sql_text return sql_text
security.declareProtected( Permissions.AccessContentsInformation, 'asParentSqlExpression' ) security.declareProtected( Permissions.AccessContentsInformation, 'asParentSqlExpression' )
def getParentSqlExpression(self, table = 'catalog', strict_membership = 0): def getParentSqlExpression(self, table = 'catalog', strict_membership = 0):
""" """
...@@ -1617,7 +1618,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ): ...@@ -1617,7 +1618,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
return self._getCategoryTool().isAcquiredMemberOf(self, category) return self._getCategoryTool().isAcquiredMemberOf(self, category)
# Aliases # Aliases
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getTitleOrId') 'getTitleOrId')
def getTitleOrId(self): def getTitleOrId(self):
""" """
...@@ -2161,7 +2162,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ): ...@@ -2161,7 +2162,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
# Then get the first line of edit_workflow # Then get the first line of edit_workflow
return history[0].get('time', None) return history[0].get('time', None)
if hasattr(self, 'CreationDate') : if hasattr(self, 'CreationDate') :
return self.CreationDate() return asDate(self.CreationDate())
return None return None
security.declareProtected(Permissions.AccessContentsInformation, 'getModificationDate') security.declareProtected(Permissions.AccessContentsInformation, 'getModificationDate')
...@@ -2250,7 +2251,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ): ...@@ -2250,7 +2251,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
# go back to previous situation (class based definition) # go back to previous situation (class based definition)
if self.__dict__.has_key('isIndexable'): delattr(self, 'isIndexable') if self.__dict__.has_key('isIndexable'): delattr(self, 'isIndexable')
if self.__dict__.has_key('isTemplate'): delattr(self, 'isTemplate') if self.__dict__.has_key('isTemplate'): delattr(self, 'isTemplate')
# Add to catalog # Add to catalog
self.reindexObject() self.reindexObject()
......
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