def update(self):
        engine = pagetemplatefile.getEngine()
        context = aq_inner(self.context)

        sort_info = context.restrictedTraverse(
            '@@sort_info').getSortInfo()
        crit_fields, criteria = context.restrictedTraverse(
            '@@criteria_form').criteriaFields()

        columns = getattr(context, 'columns', ())
        ordered = []
        sorts = {}
        has_filters = False
        has_sums = False
        for column_obj in columns and columns.contentValues():
            field = column_obj.Field()
            column = dict(
                field=field,
                name=column_obj.Title(),
                link=column_obj.getLink(),
                id_=column_obj.getId(),
                )

            sort = column_obj.getSort()
            if sort:
                sort_crit = context[sort]
                sort_field = sort_crit.Field()
                column['sort'] = sort_field
                sorts[sort_field] = sort_crit.getId()
                # Remove column sorts from the batch_macro sorts.
                # Only want to do this for views that use columns so
                # we modify the values from the sort_info view.
                # TODO This depends on memoize, maybe inappropriate
                sort_info['ids'].remove(sort_field)

            filter_ = column_obj.getFilter()
            if filter_:
                has_filters = True
                filter_field = context[filter_].Field()
                column['filter_'] = criteria[filter_field]
                # Remove column filters from the form criteria fields.
                # Only want to do this for views that use columns so
                # we modify the values from the criteria_form view.
                # TODO This depends on memoize, maybe inappropriate
                crit_fields.remove(filter_field)

            expr = column_obj.getExpression()
            if expr:
                key, expr = taldefs.parseSubstitution(expr)
                column['expr'] = engine.compile(expr)
                column['structure'] = (key == 'structure')

            column['has_sum'] = has_sum = column_obj.getSum()
            if has_sum:
                has_sums = True

            ordered.append(column)
        return ordered, sorts, has_filters, has_sums
Example #2
0
 def emitSubstitution(self, arg, attrDict={}):
     key, expr = parseSubstitution(arg)
     cexpr = self.compileExpression(expr)
     program = self.popProgram()
     if key == "text":
         self.emit("insertText", cexpr, program)
     else:
         assert key == "structure"
         self.emit("insertStructure", cexpr, attrDict, program)
Example #3
0
 def emitTranslation(self, msgid, i18ndata):
     program = self.popProgram()
     if i18ndata is None:
         self.emit('insertTranslation', msgid, program)
     else:
         key, expr = parseSubstitution(i18ndata)
         cexpr = self.compileExpression(expr)
         assert key == 'text'
         self.emit('insertTranslation', msgid, program, cexpr)
Example #4
0
 def emitSubstitution(self, arg, attrDict={}):
     key, expr = parseSubstitution(arg)
     cexpr = self.compileExpression(expr)
     program = self.popProgram()
     if key == "text":
         self.emit("insertText", cexpr, program)
     else:
         assert key == "structure"
         self.emit("insertStructure", cexpr, attrDict, program)
Example #5
0
 def emitTranslation(self, msgid, i18ndata):
     program = self.popProgram()
     if i18ndata is None:
         self.emit('insertTranslation', msgid, program)
     else:
         key, expr = parseSubstitution(i18ndata)
         cexpr = self.compileExpression(expr)
         assert key == 'text'
         self.emit('insertTranslation', msgid, program, cexpr)
Example #6
0
 def emitI18nSubstitution(self, arg, attrDict={}):
     # TODO: Code duplication is BAD, we need to fix it later
     key, expr = parseSubstitution(arg)
     cexpr = self.compileExpression(expr)
     program = self.popProgram()
     if key == "text":
         self.emit("insertI18nText", cexpr, program)
     else:
         assert key == "structure"
         self.emit("insertI18nStructure", cexpr, attrDict, program)
Example #7
0
 def emitI18nSubstitution(self, arg, attrDict={}):
     # TODO: Code duplication is BAD, we need to fix it later
     key, expr = parseSubstitution(arg)
     cexpr = self.compileExpression(expr)
     program = self.popProgram()
     if key == "text":
         self.emit("insertI18nText", cexpr, program)
     else:
         assert key == "structure"
         self.emit("insertI18nStructure", cexpr, attrDict, program)
Example #8
0
 def emitOnError(self, name, onError, TALtag, isend):
     block = self.popProgram()
     key, expr = parseSubstitution(onError)
     cexpr = self.compileExpression(expr)
     if key == "text":
         self.emit("insertText", cexpr, [])
     else:
         assert key == "structure"
         self.emit("insertStructure", cexpr, {}, [])
     if TALtag:
         self.emitOptTag(name, (None, 1), isend)
     else:
         self.emitEndTag(name)
     handler = self.popProgram()
     self.emit("onError", block, handler)
Example #9
0
 def emitOnError(self, name, onError, TALtag, isend):
     block = self.popProgram()
     key, expr = parseSubstitution(onError)
     cexpr = self.compileExpression(expr)
     if key == "text":
         self.emit("insertText", cexpr, [])
     else:
         assert key == "structure"
         self.emit("insertStructure", cexpr, {}, [])
     if TALtag:
         self.emitOptTag(name, (None, 1), isend)
     else:
         self.emitEndTag(name)
     handler = self.popProgram()
     self.emit("onError", block, handler)