[gen] Minor improvements.

This commit is contained in:
Gaetan Delannay 2014-08-05 14:53:08 +02:00
parent 636def8d24
commit 9cccdebe24
4 changed files with 21 additions and 8 deletions

View file

@ -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)()
# ------------------------------------------------------------------------------

View file

@ -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';

View file

@ -505,13 +505,13 @@ class ToolWrapper(AbstractWrapper):
</x>
</p>
<table width="100%">
<tr>
<tr valign="top">
<!-- Search description -->
<td if="uiSearch.translatedDescr">
<span class="discreet">:uiSearch.translatedDescr</span><br/>
</td>
<!-- (Top) navigation -->
<td align=":dright" width="25%"><x>:tool.pxNavigate</x></td>
<td align=":dright" width="150px"><x>:tool.pxNavigate</x></td>
</tr>
</table>

View file

@ -49,7 +49,7 @@ class AbstractWrapper(object):
pxNavigationStrip = Px('''
<table width="100%">
<tr>
<tr valign="top">
<!-- Breadcrumb -->
<td var="sup=zobj.getSupBreadCrumb();
breadcrumb=zobj.getBreadCrumb(inPopup=inPopup);
@ -65,7 +65,7 @@ class AbstractWrapper(object):
<x if="sub">::sub</x>
</td>
<!-- Object navigation -->
<td align=":dright">:obj.pxNavigateSiblings</td>
<td align=":dright" width="150px">:obj.pxNavigateSiblings</td>
</tr>
</table>
<!-- Object phases and pages -->
@ -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')">
<!-- If an action is defined, execute it on p_zobj or on p_field. -->
<x if="action and not field" var2="x=getattr(actionObj, action)()"></x>
<x if="action and field" var2="x=getattr(field, action)(actionObj)"></x>
<x if="action" var2="x=ztool.executeAjaxAction(action, obj, field)"></x>
<!-- Then, call the PX on p_obj or on p_field. -->
<x if="not field">:getattr(obj, px[0])</x>
@ -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)
# ------------------------------------------------------------------------------