Package qm :: Package external :: Package DocumentTemplate :: Module DT_Return
[hide private]
[frames] | no frames]

Source Code for Module qm.external.DocumentTemplate.DT_Return

 1  ############################################################################## 
 2  # 
 3  # Copyright (c) 2002 Zope Corporation and Contributors. All Rights Reserved. 
 4  # 
 5  # This software is subject to the provisions of the Zope Public License, 
 6  # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution. 
 7  # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED 
 8  # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
 9  # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS 
10  # FOR A PARTICULAR PURPOSE 
11  # 
12  ############################################################################## 
13  __version__='$Revision: 1069 $'[11:-2] 
14   
15  from DT_Util import parse_params, name_param, html_quote, str 
16  import string, sys 
17  from string import find, split, join, atoi, rfind 
18   
19 -class ReturnTag:
20 name='return' 21 expr=None 22
23 - def __init__(self, args):
24 args = parse_params(args, name='', expr='') 25 name, expr = name_param(args,'var',1) 26 self.__name__, self.expr = name, expr
27
28 - def render(self, md):
29 name=self.__name__ 30 val=self.expr 31 if val is None: 32 val = md[name] 33 else: 34 val=val.eval(md) 35 36 raise DTReturn(val)
37 38 __call__ = render 39
40 -class DTReturn:
41 - def __init__(self, v):
42 self.v = v
43