From 9cccdebe24a964fbdc390a0b47b487ac63a1bfbd Mon Sep 17 00:00:00 2001 From: Gaetan Delannay Date: Tue, 5 Aug 2014 14:53:08 +0200 Subject: [PATCH] [gen] Minor improvements. --- gen/mixins/ToolMixin.py | 12 ++++++++++++ gen/ui/appy.js | 1 + gen/wrappers/ToolWrapper.py | 4 ++-- gen/wrappers/__init__.py | 12 ++++++------ 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/gen/mixins/ToolMixin.py b/gen/mixins/ToolMixin.py index 1221780..2b50bab 100644 --- a/gen/mixins/ToolMixin.py +++ b/gen/mixins/ToolMixin.py @@ -1422,4 +1422,16 @@ class ToolMixin(BaseMixin): if version < self.ieMin: mapping = {'version': version, 'min': self.ieMin} return self.translate('wrong_browser', mapping=mapping) + + def executeAjaxAction(self, action, obj, field): + '''When PX "pxAjax" is called to get some chunk of XHTML via an Ajax + request, a server action can be executed before rendering the XHTML + chunk. This method executes this action.''' + if action.startswith(':'): + # The action corresponds to a method on Appy p_obj. + getattr(obj, action[1:])() + else: + # The action must be executed on p_field if present, on obj.o else. + if field: getattr(field, action)(obj.o) + else: getattr(obj.o, action)() # ------------------------------------------------------------------------------ diff --git a/gen/ui/appy.js b/gen/ui/appy.js index 58ca81c..01a10a2 100644 --- a/gen/ui/appy.js +++ b/gen/ui/appy.js @@ -803,6 +803,7 @@ function askConfirm(actionType, action, msg, showComment) { var confirmForm = document.getElementById('confirmActionForm'); confirmForm.actionType.value = actionType; confirmForm.action.value = action; + if (!msg) msg = action_confirm; var commentArea = document.getElementById('commentArea'); if (showComment) commentArea.style.display = 'block'; else commentArea.style.display = 'none'; diff --git a/gen/wrappers/ToolWrapper.py b/gen/wrappers/ToolWrapper.py index 98df25a..f9b5aa6 100644 --- a/gen/wrappers/ToolWrapper.py +++ b/gen/wrappers/ToolWrapper.py @@ -505,13 +505,13 @@ class ToolWrapper(AbstractWrapper):

- + - +
:uiSearch.translatedDescr
:tool.pxNavigate:tool.pxNavigate
diff --git a/gen/wrappers/__init__.py b/gen/wrappers/__init__.py index 06b49e6..971572f 100644 --- a/gen/wrappers/__init__.py +++ b/gen/wrappers/__init__.py @@ -49,7 +49,7 @@ class AbstractWrapper(object): pxNavigationStrip = Px(''' - + - +
::sub :obj.pxNavigateSiblings:obj.pxNavigateSiblings
@@ -631,8 +631,7 @@ class AbstractWrapper(object): req=ztool.REQUEST; resp=req.RESPONSE; dummy=setattr(req, 'pxContext', _ctx_); lang=ztool.getUserLanguage(); q=ztool.quote; - action=req.get('action', None); - actionObj=(action and action.startswith(':')) and obj or zobj; + action=req.get('action', ''); px=req['px'].split(':'); inPopup=req.get('popup') == '1'; className=(len(px) == 3) and px[0] or None; @@ -647,8 +646,7 @@ class AbstractWrapper(object): x=resp.setHeader('CacheControl', 'no-cache')"> - - + :getattr(obj, px[0]) @@ -1134,4 +1132,6 @@ class AbstractWrapper(object): localRoles = PersistentMapping({ self.o.creator: ['Owner'] }) self.o.__ac_local_roles__ = localRoles return localRoles + + def raiseUnauthorized(self, msg=None): return self.o.raiseUnauthorized(msg) # ------------------------------------------------------------------------------