diff --git a/gen/ogone.py b/gen/ogone.py index cb6c3b0..9bdf7ac 100644 --- a/gen/ogone.py +++ b/gen/ogone.py @@ -2,6 +2,17 @@ import sha from appy import Object from appy.gen import Type +from appy.px import Px + +view = Px(''' +

Hello PX world.

+ +
+ :x : :value[x] +
+ :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') # ------------------------------------------------------------------------------ diff --git a/gen/ui/widgets/ogone.pt b/gen/ui/widgets/ogone.pt index 739c32c..cb4f745 100644 --- a/gen/ui/widgets/ogone.pt +++ b/gen/ui/widgets/ogone.pt @@ -2,6 +2,7 @@ var "value" is misused and contains the contact params for Ogone. The form for sending the payment request to Ogone. +

@@ -13,6 +14,9 @@
+ Ogone PX test +
PX
+
Edit macro (none) diff --git a/pod/buffers.py b/pod/buffers.py index 7ebf3d1..0c7df0a 100644 --- a/pod/buffers.py +++ b/pod/buffers.py @@ -150,7 +150,14 @@ class Buffer: self.write('<%s' % elem) for name, value in attrs.items(): if ignoreAttrs and (name in ignoreAttrs): continue - self.write(' %s=%s' % (name, quoteattr(value))) + # If the value begins with ':', it is a Python expression. Else, + # it is a static value. + if not value.startswith(':'): + self.write(' %s=%s' % (name, quoteattr(value))) + else: + self.write(' %s="' % name) + self.addExpression(value[1:]) + self.write('"') if insertAttributesHook: res = self.addAttributes() else: @@ -605,8 +612,11 @@ class MemoryBuffer(Buffer): try: result.dumpContent(evalEntry.evaluate(self.env.context)) except Exception, e: - PodError.dump(result, EVAL_EXPR_ERROR % ( - evalEntry.expr, e), dumpTb=False) + if self.caller() == 'pod': + PodError.dump(result, EVAL_EXPR_ERROR % ( + evalEntry.expr, e), dumpTb=False) + else: # px + raise Exception(EVAL_EXPR_ERROR %(evalEntry.expr,e)) elif isinstance(evalEntry, Attributes): result.write(evalEntry.evaluate(self.env.context)) else: # It is a subBuffer @@ -621,4 +631,9 @@ class MemoryBuffer(Buffer): def clean(self): '''Cleans the buffer content.''' self.content = u'' + + def caller(self): + '''Returns "pod" if the caller is appy.pod, "px" if it is appy.px.''' + if self.env.__class__.__name__ == 'PxEnvironment': return 'px' + return 'pod' # ------------------------------------------------------------------------------