[px] Implemented attribute values containing Python expressions, and errors management.

This commit is contained in:
Gaetan Delannay 2013-03-16 00:02:16 +01:00
parent be3cc6ae59
commit bf98b2cdf2
3 changed files with 35 additions and 3 deletions

View file

@ -2,6 +2,17 @@
import sha
from appy import Object
from appy.gen import Type
from appy.px import Px
view = Px('''
<p>Hello PX world.</p>
<x for="x in value.keys()">
<div if="len(x) &lt; 5">
<x>:x</x> : <x>:value[x]</x>
</div>
<a href=":'http://www.cetic.be/%s' % value[x]">:x</a>
</x>
''')
# ------------------------------------------------------------------------------
class OgoneConfig:
@ -146,4 +157,6 @@ class Ogone(Type):
# some URL, use it. Else, use the view page of p_obj.
if not url: url = obj.absolute_url()
obj.goto(url)
def getPx(self, context): return view(context).encode('utf-8')
# ------------------------------------------------------------------------------

View file

@ -2,6 +2,7 @@
<metal:view define-macro="view">
<tal:comment replace="nothing">var "value" is misused and contains the contact params for Ogone.</tal:comment>
<tal:comment replace="nothing">The form for sending the payment request to Ogone.</tal:comment>
<p tal:content="value"></p>
<form method="post" id="form1" name="form1"
tal:define="env value/env"
tal:attributes="action string: https://secure.ogone.com/ncol/$env/orderstandard.asp">
@ -13,6 +14,9 @@
<input type="image" id="submit2" name="submit2"
tal:attributes="src string: $appUrl/ui/ogone.gif; title python: _('custom_pay')"/>
</form>
<tal:comment replace="nothing">Ogone PX test</tal:comment>
<div>PX</div>
<tal:px replace="structure python: contextObj.callField(name, 'getPx', {'obj': contextObj, 'value': value})"/>
</metal:view>
<tal:comment replace="nothing">Edit macro (none)</tal:comment>