From 500637eb53e391d0155738f40d14a0313e0cf03f Mon Sep 17 00:00:00 2001 From: Gaetan Delannay Date: Tue, 12 Jan 2010 08:58:40 +0100 Subject: [PATCH] Minor bugfixes. --- gen/__init__.py | 4 ++- gen/plone25/generator.py | 2 ++ gen/plone25/mixins/__init__.py | 33 +++++++++---------- gen/plone25/templates/global_statusmessage.pt | 20 +++++++++++ gen/plone25/workflow.py | 2 +- 5 files changed, 42 insertions(+), 19 deletions(-) create mode 100644 gen/plone25/templates/global_statusmessage.pt diff --git a/gen/__init__.py b/gen/__init__.py index 5a40e6e..97fcfc0 100755 --- a/gen/__init__.py +++ b/gen/__init__.py @@ -1,5 +1,6 @@ # ------------------------------------------------------------------------------ import re, time +from appy.shared.utils import Traceback from appy.gen.utils import sequenceTypes, PageDescr from appy.shared.data import countries @@ -436,7 +437,8 @@ class Action(Type): # anything), we consider the action as successfull. if res[0] == None: res[0] = True except Exception, e: - res = (False, str(e)) + res = (False, 'An error occurred. %s' % str(e)) + obj.log(Traceback.get(), type='error') return res class Info(Type): diff --git a/gen/plone25/generator.py b/gen/plone25/generator.py index 09f8204..ede67e5 100644 --- a/gen/plone25/generator.py +++ b/gen/plone25/generator.py @@ -162,6 +162,8 @@ class Generator(AbstractGenerator): self.copyFile('Portlet.pt', self.repls, destName='%s.pt' % self.portletName, destFolder=self.skinsFolder) self.copyFile('tool.gif', {}) + self.copyFile( + 'global_statusmessage.pt', {}, destFolder=self.skinsFolder) self.copyFile('Styles.css.dtml',self.repls, destFolder=self.skinsFolder, destName = '%s.css.dtml' % self.applicationName) self.copyFile('IEFixes.css.dtml',self.repls,destFolder=self.skinsFolder) diff --git a/gen/plone25/mixins/__init__.py b/gen/plone25/mixins/__init__.py index 810bcd6..02233b7 100644 --- a/gen/plone25/mixins/__init__.py +++ b/gen/plone25/mixins/__init__.py @@ -775,6 +775,7 @@ class AbstractMixin: msg = self.translate(u'Your content\'s status has been modified.', domain='plone') self.plone_utils.addPortalMessage(msg) + self.reindexObject() return self.goto(urlBack) def callAppySelect(self, selectMethod, brains): @@ -1110,24 +1111,22 @@ class AbstractMixin: performs inter-field validation. This way, the user must first correct individual fields before being confronted to potential inter-fields validation errors.''' - obj = self._appy_getWrapper() + obj = self.appy() + if not hasattr(obj, 'validate'): return appyRequest = getAppyRequest(REQUEST, obj) - try: - appyErrors = ValidationErrors() - obj.validate(appyRequest, appyErrors) - # This custom "validate" method may have added fields in the given - # ValidationErrors instance. Now we must fill the Zope "errors" dict - # based on it. For every error message that is not a string, - # we replace it with the standard validation error for the - # corresponding field. - for key, value in appyErrors.__dict__.iteritems(): - resValue = value - if not isinstance(resValue, basestring): - msgId = '%s_valid' % self.getLabelPrefix(key) - resValue = self.utranslate(msgId, domain=self.i18nDomain) - errors[key] = resValue - except AttributeError: - pass + appyErrors = ValidationErrors() + obj.validate(appyRequest, appyErrors) + # This custom "validate" method may have added fields in the given + # ValidationErrors instance. Now we must fill the Zope "errors" dict + # based on it. For every error message that is not a string, + # we replace it with the standard validation error for the + # corresponding field. + for key, value in appyErrors.__dict__.iteritems(): + resValue = value + if not isinstance(resValue, basestring): + msgId = '%s_valid' % self.getLabelPrefix(key) + resValue = self.utranslate(msgId, domain=self.i18nDomain) + errors[key] = resValue def _appy_getPortalType(self, request): '''Guess the portal_type of p_self from info about p_self and diff --git a/gen/plone25/templates/global_statusmessage.pt b/gen/plone25/templates/global_statusmessage.pt new file mode 100644 index 0000000..5114972 --- /dev/null +++ b/gen/plone25/templates/global_statusmessage.pt @@ -0,0 +1,20 @@ + + + + Single message from portal_status_message request key +
+ + Messages added via plone_utils + + +
+
+
+
+ + diff --git a/gen/plone25/workflow.py b/gen/plone25/workflow.py index acad73f..cc67d9a 100644 --- a/gen/plone25/workflow.py +++ b/gen/plone25/workflow.py @@ -160,7 +160,7 @@ def do(transitionName, stateChange, logger): # We do not notify if the "notify" flag in the flavour is disabled. doNotify = False if doAction or doNotify: - obj = ploneObj._appy_getWrapper(force=True) + obj = ploneObj.appy() if doAction: if type(transition.action) in (tuple, list): # We need to execute a list of actions