diff --git a/gen/mixins/ToolMixin.py b/gen/mixins/ToolMixin.py
index 618cb3a..82ffdac 100644
--- a/gen/mixins/ToolMixin.py
+++ b/gen/mixins/ToolMixin.py
@@ -24,6 +24,8 @@ jsMessages = ('no_elem_selected', 'delete_confirm', 'unlink_confirm',
# ------------------------------------------------------------------------------
class ToolMixin(BaseMixin):
_appy_meta_type = 'Tool'
+ xhtmlEncoding = 'text/html;charset=UTF-8'
+
def getPortalType(self, metaTypeOrAppyClass):
'''Returns the name of the portal_type that is based on
p_metaTypeOrAppyType.'''
@@ -40,7 +42,7 @@ class ToolMixin(BaseMixin):
def home(self):
'''Returns the content of px ToolWrapper.pxHome.'''
tool = self.appy()
- return tool.pxHome({'self': tool}).encode('utf-8')
+ return tool.pxHome({'self': tool})
def getHomePage(self):
'''Return the home page when a user hits the app.'''
diff --git a/gen/wrappers/ToolWrapper.py b/gen/wrappers/ToolWrapper.py
index e1bc220..04841df 100644
--- a/gen/wrappers/ToolWrapper.py
+++ b/gen/wrappers/ToolWrapper.py
@@ -21,8 +21,13 @@ NOT_UNO_ENABLED_PYTHON = '"%s" is not a UNO-enabled Python interpreter. ' \
# ------------------------------------------------------------------------------
class ToolWrapper(AbstractWrapper):
- pxHome = Px('''
+ ''', template=AbstractWrapper.pxTemplate, hook='content')
def validPythonWithUno(self, value):
'''This method represents the validator for field unoEnabledPython.'''
diff --git a/gen/wrappers/__init__.py b/gen/wrappers/__init__.py
index e060d1d..b8107a2 100644
--- a/gen/wrappers/__init__.py
+++ b/gen/wrappers/__init__.py
@@ -28,9 +28,211 @@ class AbstractWrapper(object):
instance of this class.'''
pxTemplate = Px('''
-
- :self.title
+
+
+ :_('app_name')
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
:content
diff --git a/pod/actions.py b/pod/actions.py
index 2727f33..37e7fa2 100644
--- a/pod/actions.py
+++ b/pod/actions.py
@@ -48,6 +48,9 @@ class BufferAction:
self.fromExpr = fromExpr
# When an error occurs, must we raise it or write it into the buffer?
self.raiseErrors = not self.buffer.pod
+ # Several actions may co-exist for the same buffer, as a chain of
+ # BufferAction instances, defined via the following attribute.
+ self.subAction = None
def getExceptionLine(self, e):
'''Gets the line describing exception p_e, containing the pathname of
@@ -120,6 +123,13 @@ class BufferAction:
if not error:
result.write(feRes)
+ def addSubAction(self, action):
+ '''Adds p_action as a sub-action of this action.'''
+ if not self.subAction:
+ self.subAction = action
+ else:
+ self.subAction.addSubAction(action)
+
class IfAction(BufferAction):
'''Action that determines if we must include the content of the buffer in
the result or not.'''
@@ -227,7 +237,12 @@ class ForAction(BufferAction):
result.dumpEndElement(Row.OD.elem)
result.dumpStartElement(Row.OD.elem, rowAttributes)
currentColIndex = 0
- self.evaluateBuffer(result, context)
+ # If a sub-action is defined, execute it.
+ if self.subAction:
+ self.subAction.execute(result, context)
+ else:
+ # Evaluate the buffer directly.
+ self.evaluateBuffer(result, context)
# Cell: increment the current column index
if isCell:
currentColIndex += 1
@@ -307,8 +322,12 @@ class VariablesAction(BufferAction):
hidden[name] = context[name]
# Store the result into the context
context[name] = vRes
- # Evaluate the buffer
- self.evaluateBuffer(result, context)
+ # If a sub-action is defined, execute it.
+ if self.subAction:
+ self.subAction.execute(result, context)
+ else:
+ # Evaluate the buffer directly.
+ self.evaluateBuffer(result, context)
# Restore hidden variables if any
if hidden: context.update(hidden)
# Delete not-hidden variables
diff --git a/pod/buffers.py b/pod/buffers.py
index 5cb4ee3..22dd6f0 100644
--- a/pod/buffers.py
+++ b/pod/buffers.py
@@ -471,6 +471,9 @@ class MemoryBuffer(Buffer):
return res
def createPxAction(self, elem, actionType, statement):
+ '''Creates a PX action and link it to this buffer. If an action is
+ already linked to this buffer (in self.action), this action is
+ chained behind the last action via self.action.subAction.'''
res = 0
statement = statement.strip()
if actionType == 'for':
@@ -478,15 +481,19 @@ class MemoryBuffer(Buffer):
if not forRes:
raise ParsingError(BAD_FOR_EXPRESSION % statement)
iter, subExpr = forRes.groups()
- self.action = ForAction('for', self, subExpr, elem, False, iter,
- 'buffer', None)
+ action = ForAction('for', self, subExpr, elem, False, iter,
+ 'buffer', None)
elif actionType == 'if':
- self.action = IfAction('if', self, statement, elem, False,
- 'buffer', None)
+ action= IfAction('if', self, statement, elem, False, 'buffer', None)
elif actionType == 'var':
variables = self._getVariables(statement)
- self.action = VariablesAction('var', self, elem, False, variables,
- 'buffer', None)
+ action = VariablesAction('var', self, elem, False, variables,
+ 'buffer', None)
+ # Is it the first action for this buffer or not?
+ if not self.action:
+ self.action = action
+ else:
+ self.action.addSubAction(action)
return res
def cut(self, index, keepFirstPart):
diff --git a/px/px_parser.py b/px/px_parser.py
index e511b59..a6171fc 100644
--- a/px/px_parser.py
+++ b/px/px_parser.py
@@ -46,7 +46,7 @@ class PxParser(XmlParser):
'''PX parser that is specific for parsing PX data.'''
pxAttributes = ('var', 'for', 'if')
# No-end tags
- noEndTags = ('br', 'img')
+ noEndTags = ('br', 'img', 'link', 'input')
def __init__(self, env, caller=None):
XmlParser.__init__(self, env, caller)
@@ -56,13 +56,16 @@ class PxParser(XmlParser):
e = self.env
self.currentElem = elem
# See if we have a PX attribute among p_attrs.
+ found = False
for name in self.pxAttributes:
if attrs.has_key(name):
- # Dump the element in a new sub-buffer
- e.addSubBuffer()
- # Create the action for this buffer
+ if not found:
+ # This is the first PX attr we find.
+ # Create a sub-buffer with an action.
+ e.addSubBuffer()
+ found = True
+ # Add the action.
e.currentBuffer.createPxAction(elem, name, attrs[name])
- break
if e.isActionElem(elem):
# Add a temp element in the buffer (that will be unreferenced
# later). This way, when encountering the corresponding end element,