Commit 7e1dc330 authored by Romain Courteaud's avatar Romain Courteaud

Wrap divergent object in the object message (in order to make them more listbox friendly).


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11356 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 47e93076
...@@ -31,7 +31,7 @@ from Products.PythonScripts.Utility import allow_class ...@@ -31,7 +31,7 @@ from Products.PythonScripts.Utility import allow_class
class ObjectMessage: class ObjectMessage:
""" """
Object Message is used for notifications to user. Object Message is used for notifications to user.
""" """
def __init__(self, object_relative_url='', message='', mapping={}, **kw): def __init__(self, object_relative_url='', message='', mapping={}, **kw):
...@@ -46,13 +46,14 @@ class ObjectMessage: ...@@ -46,13 +46,14 @@ class ObjectMessage:
Return the message translated Return the message translated
""" """
from Products.ERP5Type.Message import Message from Products.ERP5Type.Message import Message
return Message(domain='erp5_ui', message=self.message, mapping=self.mapping) return Message(domain='erp5_ui', message=self.message,
mapping=self.mapping)
getMessage = getTranslatedMessage getMessage = getTranslatedMessage
def edit(self, **kw): def edit(self, **kw):
""" """
set all parameters Set all parameters
""" """
self.__dict__.update(kw) self.__dict__.update(kw)
...@@ -62,6 +63,19 @@ class ObjectMessage: ...@@ -62,6 +63,19 @@ class ObjectMessage:
""" """
return getattr(self, value, None) return getattr(self, value, None)
def __getattr__(self, name):
"""
Wrap the message with the object
"""
if name.startswith('__') :
raise AttributeError, name
else:
obj = self.getObject()
if obj is not None:
return getattr(obj, name)
else:
raise AttributeError, name
def getObject(self): def getObject(self):
""" """
Get the Object Get the Object
...@@ -70,7 +84,7 @@ class ObjectMessage: ...@@ -70,7 +84,7 @@ class ObjectMessage:
request = get_request()['PARENTS'] request = get_request()['PARENTS']
if request is not None: if request is not None:
for item in request: for item in request:
if item.meta_type == 'ERP5 Site': if item.meta_type == 'ERP5 Site':
return item.restrictedTraverse(self.object_relative_url) return item.restrictedTraverse(self.object_relative_url)
return None return None
......
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