Home | Trees | Indices | Help |
---|
|
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 '''Raising exceptions 14 15 Errors can be raised from DTML using the 'raise' tag. 16 17 For example:: 18 19 <!--#if expr="condition_that_tests_input"--> 20 <!--#raise type="Input Error"--> 21 The value you entered is not valid 22 <!--#/raise--> 23 <!--#/if--> 24 25 ''' 26 __rcs_id__='$Id: DT_Raise.py 1069 2008-11-13 21:55:43Z stefan $' 27 __version__='$Revision: 1069 $'[11:-2] 28 29 from DT_Util import parse_params, name_param, render_blocks, str 3032 blockContinuations=() 33 name='raise' 34 expr='' 355937 38 tname, args, section = blocks[0] 39 self.section=section.blocks 40 args=parse_params(args, type='', expr='') 41 self.__name__, self.expr = name_param(args, 'raise', 1, attr='type')4244 expr=self.expr 45 if expr is None: 46 t=self.__name__ 47 if t[-5:]=='Error' and __builtins__.has_key(t): 48 t=__builtins__[t] 49 else: 50 try: t=expr.eval(md) 51 except: t='Invalid Error Type Expression' 52 53 try: v=render_blocks(self.section,md) 54 except: v='Invalid Error Value' 55 56 raise t, v57 58 __call__=render
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Fri Dec 23 12:30:47 2011 | http://epydoc.sourceforge.net |