Home | Trees | Index | Help |
---|
|
1 ############################################################################## 2 # 3 # Zope Public License (ZPL) Version 1.0 4 # ------------------------------------- 5 # 6 # Copyright (c) Digital Creations. All rights reserved. 7 # 8 # This license has been certified as Open Source(tm). 9 # 10 # Redistribution and use in source and binary forms, with or without 11 # modification, are permitted provided that the following conditions are 12 # met: 13 # 14 # 1. Redistributions in source code must retain the above copyright 15 # notice, this list of conditions, and the following disclaimer. 16 # 17 # 2. Redistributions in binary form must reproduce the above copyright 18 # notice, this list of conditions, and the following disclaimer in 19 # the documentation and/or other materials provided with the 20 # distribution. 21 # 22 # 3. Digital Creations requests that attribution be given to Zope 23 # in any manner possible. Zope includes a "Powered by Zope" 24 # button that is installed by default. While it is not a license 25 # violation to remove this button, it is requested that the 26 # attribution remain. A significant investment has been put 27 # into Zope, and this effort will continue if the Zope community 28 # continues to grow. This is one way to assure that growth. 29 # 30 # 4. All advertising materials and documentation mentioning 31 # features derived from or use of this software must display 32 # the following acknowledgement: 33 # 34 # "This product includes software developed by Digital Creations 35 # for use in the Z Object Publishing Environment 36 # (http://www.zope.org/)." 37 # 38 # In the event that the product being advertised includes an 39 # intact Zope distribution (with copyright and license included) 40 # then this clause is waived. 41 # 42 # 5. Names associated with Zope or Digital Creations must not be used to 43 # endorse or promote products derived from this software without 44 # prior written permission from Digital Creations. 45 # 46 # 6. Modified redistributions of any form whatsoever must retain 47 # the following acknowledgment: 48 # 49 # "This product includes software developed by Digital Creations 50 # for use in the Z Object Publishing Environment 51 # (http://www.zope.org/)." 52 # 53 # Intact (re-)distributions of any official Zope release do not 54 # require an external acknowledgement. 55 # 56 # 7. Modifications are encouraged but must be packaged separately as 57 # patches to official Zope releases. Distributions that do not 58 # clearly separate the patches from the original work must be clearly 59 # labeled as unofficial distributions. Modifications which do not 60 # carry the name Zope may be packaged in any form, as long as they 61 # conform to all of the clauses above. 62 # 63 # 64 # Disclaimer 65 # 66 # THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY 67 # EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 68 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 69 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL CREATIONS OR ITS 70 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 71 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 72 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 73 # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 74 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 75 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 76 # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 77 # SUCH DAMAGE. 78 # 79 # 80 # This software consists of contributions made by Digital Creations and 81 # many individuals on behalf of Digital Creations. Specific 82 # attributions are listed in the accompanying credits file. 83 # 84 ############################################################################## 85 __doc__='''Conditional insertion 86 87 Conditional insertion is performed using 'if' and 'else' 88 commands. 89 90 To include text when an object is true using the EPFS 91 format, use:: 92 93 %(if name)[ 94 text 95 %(if name)] 96 97 To include text when an object is true using the HTML 98 format, use:: 99 100 <!--#if name--> 101 text 102 <!--#/if name--> 103 104 where 'name' is the name bound to the object. 105 106 To include text when an object is false using the EPFS 107 format, use:: 108 109 %(else name)[ 110 text 111 %(else name)] 112 113 To include text when an object is false using the HTML 114 format, use:: 115 116 <!--#else name--> 117 text 118 <!--#/else name--> 119 120 Finally to include text when an object is true and to 121 include different text when the object is false using the 122 EPFS format, use:: 123 124 %(if name)[ 125 true text 126 %(if name)] 127 %(else name)[ 128 false text 129 %(else name)] 130 131 and to include text when an object is true and to 132 include different text when the object is false using the 133 HTML format, use:: 134 135 <!--#if name--> 136 true text 137 <!--#else name--> 138 false text 139 <!--#/if name--> 140 141 Notes: 142 143 - if a variable is nor defined, it is considered to be false. 144 145 - A variable if only evaluated once in an 'if' tag. If the value 146 is used inside the tag, including in enclosed tags, the 147 variable is not reevaluated. 148 149 ''' 150 __rcs_id__='$Id: DT_If.py 694 2003-04-16 02:53:50Z sc $' 151 __version__='$Revision: 694 $'[11:-2] 152 153 from DT_Util import ParseError, parse_params, name_param, str 154156 blockContinuations='else','elif' 157 name='if' 158 elses=None 159 expr='' 160196 208 212162 163 tname, args, section = blocks[0] 164 args=parse_params(args, name='', expr='') 165 name,expr=name_param(args,'if',1) 166 self.__name__= name 167 if expr is None: cond=name 168 else: cond=expr.eval 169 sections=[cond, section.blocks] 170 171 if blocks[-1][0]=='else': 172 tname, args, section = blocks[-1] 173 del blocks[-1] 174 args=parse_params(args, name='') 175 if args: 176 ename,expr=name_param(args,'else',1) 177 if ename != name: 178 raise ParseError, ('name in else does not match if', 'in') 179 elses=section.blocks 180 else: elses=None 181 182 for tname, args, section in blocks[1:]: 183 if tname=='else': 184 raise ParseError, ( 185 'more than one else tag for a single if tag', 'in') 186 args=parse_params(args, name='', expr='') 187 name,expr=name_param(args,'elif',1) 188 if expr is None: cond=name 189 else: cond=expr.eval 190 sections.append(cond) 191 sections.append(section.blocks) 192 193 if elses is not None: sections.append(elses) 194 195 self.simple_form=tuple(sections)
Home | Trees | Index | Help |
---|
Generated by Epydoc 3.0alpha2 on Fri Sep 28 00:58:41 2007 | http://epydoc.sf.net |