def update(self): self.tiles = [] self.tag = self.data.get("wrapper", "tal:block") tiles = self.data.get("tiles", "").strip().splitlines() context = aq_inner(self.context) request = self.request globals = None for tile in tiles: result = self.TILE_EXPR.match(tile) if not result: continue condition = result.group("condition") if condition: compiled = _compiles.get(condition) if compiled is None: compiled = _compiles[condition] = compile( condition, "<string>", "eval") if globals is None: globals = dict( context=context, request=request, view_type=viewType(context, request), ) if not eval(compiled, globals): continue tile = getTile(context, request, result.group("name")) self.tiles.append(tile)
def __call__(self, econtext): name = super(TileExpression, self).__call__(econtext) context = econtext.vars["context"] request = econtext.vars["request"] tile = getTile(context, request, name) if tile is None: # XXX Use custom exception? log.warning("Request for unknown tile %s", name) return "" return Markup(tile())
def update(self): self.tiles=[] self.tag=self.data.get("wrapper", "tal:block") tiles=self.data.get("tiles", "").strip().splitlines() context=aq_inner(self.context) request=self.request globals=None for tile in tiles: result=self.TILE_EXPR.match(tile) if not result: continue condition=result.group("condition") if condition: compiled=_compiles.get(condition) if compiled is None: compiled=_compiles[condition]=compile(condition, "<string>", "eval") if globals is None: globals=dict(context=context, request=request, view_type=viewType(context, request)) if not eval(compiled, globals): continue tile=getTile(context, request, result.group("name")) self.tiles.append(tile)
def __call__(self, context, request, name): tile = getTile(context, request, name) if tile is None: # XXX Use custom exception? log.warn('Request for unknown tile %s', name) return '' return SimpleLiteral(tile())
def __call__(self, context, request, name): tile = getTile(context, request, name) if tile is None: # XXX Use custom exception? log.warn('Request for unknown tile %s', name) return u'' return SimpleLiteral(tile())