PK6>g4>Fzope/__init__.py# namespace package boilerplate try: __import__('pkg_resources').declare_namespace(__name__) except ImportError, e: from pkgutil import extend_path __path__ = extend_path(__path__, __name__) PKm4L<zope/__init__.pyc; h Dc@sOyedieWn1ej o%ZdklZeeeZnXdS(s pkg_resources(s extend_pathN(s __import__sdeclare_namespaces__name__s ImportErrorsespkgutils extend_paths__path__(ses extend_paths__path__((s+build/bdist.linux-i686/egg/zope/__init__.pys?s PKҾ4zope/tales/__init__.py############################################################################## # # Copyright (c) 2001, 2002 Zope Corporation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Template Attribute Language - Expression Syntax $Id: __init__.py 27165 2004-08-17 11:20:31Z hdima $ """ PKҾ4@5OOzope/tales/tales.py############################################################################## # # Copyright (c) 2001, 2002 Zope Corporation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """TALES An implementation of a TAL expression engine $Id: tales.py 27081 2004-08-12 19:56:31Z srichter $ """ import re from zope.interface import implements try: from zope import tal except ImportError: tal = None if tal: from zope.tal.interfaces import ITALExpressionEngine from zope.tal.interfaces import ITALExpressionCompiler from zope.tal.interfaces import ITALExpressionErrorInfo from zope.tales.interfaces import ITALESIterator NAME_RE = r"[a-zA-Z][a-zA-Z0-9_]*" _parse_expr = re.compile(r"(%s):" % NAME_RE).match _valid_name = re.compile('%s$' % NAME_RE).match class TALESError(Exception): """Error during TALES evaluation""" class Undefined(TALESError): '''Exception raised on traversal of an undefined path''' class CompilerError(Exception): '''TALES Compiler Error''' class RegistrationError(Exception): '''Expression type or base name registration Error''' _default = object() class Iterator(object): """TALES Iterator """ if tal: implements(ITALESIterator) def __init__(self, name, seq, context): """Construct an iterator Iterators are defined for a name, a sequence, or an iterator and a context, where a context simply has a setLocal method: >>> context = Context(ExpressionEngine(), {}) >>> it = Iterator('foo', ("apple", "pear", "orange"), context) A local variable is not set until the iterator is used: >>> int("foo" in context.vars) 0 We can create an iterator on an empty sequence: >>> it = Iterator('foo', (), context) An iterator works as well: >>> it = Iterator('foo', {"apple":1, "pear":1, "orange":1}, context) >>> it.next() True >>> it = Iterator('foo', {}, context) >>> it.next() False >>> it = Iterator('foo', iter((1, 2, 3)), context) >>> it.next() True >>> it.next() True """ self._seq = seq self._iter = i = iter(seq) self._nextIndex = 0 self._name = name self._setLocal = context.setLocal # This is tricky. We want to know if we are on the last item, # but we can't know that without trying to get it. :( self._last = False try: self._next = i.next() except StopIteration: self._done = True else: self._done = False def next(self): """Advance the iterator, if possible. >>> context = Context(ExpressionEngine(), {}) >>> it = Iterator('foo', ("apple", "pear", "orange"), context) >>> bool(it.next()) True >>> context.vars['foo'] 'apple' >>> bool(it.next()) True >>> context.vars['foo'] 'pear' >>> bool(it.next()) True >>> context.vars['foo'] 'orange' >>> bool(it.next()) False >>> it = Iterator('foo', {"apple":1, "pear":1, "orange":1}, context) >>> bool(it.next()) True >>> bool(it.next()) True >>> bool(it.next()) True >>> bool(it.next()) False >>> it = Iterator('foo', (), context) >>> bool(it.next()) False >>> it = Iterator('foo', {}, context) >>> bool(it.next()) False If we can advance, set a local variable to the new value. """ # Note that these are *NOT* Python iterators! if self._done: return False self._item = v = self._next try: self._next = self._iter.next() except StopIteration: self._done = True self._last = True self._nextIndex += 1 self._setLocal(self._name, v) return True def index(self): """Get the iterator index >>> context = Context(ExpressionEngine(), {}) >>> it = Iterator('foo', ("apple", "pear", "orange"), context) >>> int(bool(it.next())) 1 >>> it.index() 0 >>> int(bool(it.next())) 1 >>> it.index() 1 >>> int(bool(it.next())) 1 >>> it.index() 2 """ index = self._nextIndex - 1 if index < 0: raise TypeError("No iteration position") return index def number(self): """Get the iterator position >>> context = Context(ExpressionEngine(), {}) >>> it = Iterator('foo', ("apple", "pear", "orange"), context) >>> int(bool(it.next())) 1 >>> it.number() 1 >>> int(bool(it.next())) 1 >>> it.number() 2 >>> int(bool(it.next())) 1 >>> it.number() 3 """ return self._nextIndex def even(self): """Test whether the position is even >>> context = Context(ExpressionEngine(), {}) >>> it = Iterator('foo', ("apple", "pear", "orange"), context) >>> it.next() True >>> it.even() False >>> it.next() True >>> it.even() True >>> it.next() True >>> it.even() False """ return not (self._nextIndex % 2) def odd(self): """Test whether the position is odd >>> context = Context(ExpressionEngine(), {}) >>> it = Iterator('foo', ("apple", "pear", "orange"), context) >>> it.next() True >>> it.odd() True >>> it.next() True >>> it.odd() False >>> it.next() True >>> it.odd() True """ return bool(self._nextIndex % 2) def parity(self): """Return 'odd' or 'even' depending on the position's parity >>> context = Context(ExpressionEngine(), {}) >>> it = Iterator('foo', ("apple", "pear", "orange"), context) >>> it.next() True >>> it.parity() 'odd' >>> it.next() True >>> it.parity() 'even' >>> it.next() True >>> it.parity() 'odd' """ if self._nextIndex % 2: return 'odd' return 'even' def letter(self, base=ord('a'), radix=26): """Get the iterator position as a lower-case letter >>> context = Context(ExpressionEngine(), {}) >>> it = Iterator('foo', ("apple", "pear", "orange"), context) >>> it.next() True >>> it.letter() 'a' >>> it.next() True >>> it.letter() 'b' >>> it.next() True >>> it.letter() 'c' """ index = self._nextIndex - 1 if index < 0: raise TypeError("No iteration position") s = '' while 1: index, off = divmod(index, radix) s = chr(base + off) + s if not index: return s def Letter(self): """Get the iterator position as an upper-case letter >>> context = Context(ExpressionEngine(), {}) >>> it = Iterator('foo', ("apple", "pear", "orange"), context) >>> it.next() True >>> it.Letter() 'A' >>> it.next() True >>> it.Letter() 'B' >>> it.next() True >>> it.Letter() 'C' """ return self.letter(base=ord('A')) def Roman(self, rnvalues=( (1000,'M'),(900,'CM'),(500,'D'),(400,'CD'), (100,'C'),(90,'XC'),(50,'L'),(40,'XL'), (10,'X'),(9,'IX'),(5,'V'),(4,'IV'),(1,'I')) ): """Get the iterator position as an upper-case roman numeral >>> context = Context(ExpressionEngine(), {}) >>> it = Iterator('foo', ("apple", "pear", "orange"), context) >>> it.next() True >>> it.Roman() 'I' >>> it.next() True >>> it.Roman() 'II' >>> it.next() True >>> it.Roman() 'III' """ n = self._nextIndex s = '' for v, r in rnvalues: rct, n = divmod(n, v) s = s + r * rct return s def roman(self): """Get the iterator position as a lower-case roman numeral >>> context = Context(ExpressionEngine(), {}) >>> it = Iterator('foo', ("apple", "pear", "orange"), context) >>> it.next() True >>> it.roman() 'i' >>> it.next() True >>> it.roman() 'ii' >>> it.next() True >>> it.roman() 'iii' """ return self.Roman().lower() def start(self): """Test whether the position is the first position >>> context = Context(ExpressionEngine(), {}) >>> it = Iterator('foo', ("apple", "pear", "orange"), context) >>> it.next() True >>> it.start() True >>> it.next() True >>> it.start() False >>> it.next() True >>> it.start() False >>> it = Iterator('foo', {}, context) >>> it.start() False >>> it.next() False >>> it.start() False """ return self._nextIndex == 1 def end(self): """Test whether the position is the last position >>> context = Context(ExpressionEngine(), {}) >>> it = Iterator('foo', ("apple", "pear", "orange"), context) >>> it.next() True >>> it.end() False >>> it.next() True >>> it.end() False >>> it.next() True >>> it.end() True >>> it = Iterator('foo', {}, context) >>> it.end() False >>> it.next() False >>> it.end() False """ return self._last def item(self): """Get the iterator value >>> context = Context(ExpressionEngine(), {}) >>> it = Iterator('foo', ("apple", "pear", "orange"), context) >>> it.next() True >>> it.item() 'apple' >>> it.next() True >>> it.item() 'pear' >>> it.next() True >>> it.item() 'orange' >>> it = Iterator('foo', {1:2}, context) >>> it.next() True >>> it.item() 1 """ if self._nextIndex == 0: raise TypeError("No iteration position") return self._item def length(self): """Get the length of the iterator sequence >>> context = Context(ExpressionEngine(), {}) >>> it = Iterator('foo', ("apple", "pear", "orange"), context) >>> it.length() 3 You can even get the length of a mapping: >>> it = Iterator('foo', {"apple":1, "pear":2, "orange":3}, context) >>> it.length() 3 But you can't get the length of an iterable which doesn't support len(): >>> class MyIter(object): ... def __init__(self, seq): ... self._next = iter(seq).next ... def __iter__(self): ... return self ... def next(self): ... return self._next() >>> it = Iterator('foo', MyIter({"apple":1, "pear":2}), context) >>> it.length() Traceback (most recent call last): ... TypeError: len() of unsized object """ return len(self._seq) class ErrorInfo(object): """Information about an exception passed to an on-error handler.""" if tal: implements(ITALExpressionErrorInfo) def __init__(self, err, position=(None, None)): if isinstance(err, Exception): self.type = err.__class__ self.value = err else: self.type = err self.value = None self.lineno = position[0] self.offset = position[1] class ExpressionEngine(object): '''Expression Engine An instance of this class keeps a mutable collection of expression type handlers. It can compile expression strings by delegating to these handlers. It can provide an expression Context, which is capable of holding state and evaluating compiled expressions. ''' if tal: implements(ITALExpressionCompiler) def __init__(self): self.types = {} self.base_names = {} self.namespaces = {} self.iteratorFactory = Iterator def registerFunctionNamespace(self, namespacename, namespacecallable): """Register a function namespace namespace - a string containing the name of the namespace to be registered namespacecallable - a callable object which takes the following parameter: context - the object on which the functions provided by this namespace will be called This callable should return an object which can be traversed to get the functions provided by the this namespace. example: class stringFuncs(object): def __init__(self,context): self.context = str(context) def upper(self): return self.context.upper() def lower(self): return self.context.lower() engine.registerFunctionNamespace('string',stringFuncs) """ self.namespaces[namespacename] = namespacecallable def getFunctionNamespace(self, namespacename): """ Returns the function namespace """ return self.namespaces[namespacename] def registerType(self, name, handler): if not _valid_name(name): raise RegistrationError, ( 'Invalid expression type name "%s".' % name) types = self.types if name in types: raise RegistrationError, ( 'Multiple registrations for Expression type "%s".' % name) types[name] = handler def getTypes(self): return self.types def registerBaseName(self, name, object): if not _valid_name(name): raise RegistrationError, 'Invalid base name "%s".' % name base_names = self.base_names if name in base_names: raise RegistrationError, ( 'Multiple registrations for base name "%s".' % name) base_names[name] = object def getBaseNames(self): return self.base_names def compile(self, expression): m = _parse_expr(expression) if m: type = m.group(1) expr = expression[m.end():] else: type = "standard" expr = expression try: handler = self.types[type] except KeyError: raise CompilerError, ( 'Unrecognized expression type "%s".' % type) return handler(type, expr, self) def getContext(self, contexts=None, **kwcontexts): if contexts is not None: if kwcontexts: kwcontexts.update(contexts) else: kwcontexts = contexts return Context(self, kwcontexts) def getCompilerError(self): return CompilerError class Context(object): '''Expression Context An instance of this class holds context information that it can use to evaluate compiled expressions. ''' if tal: implements(ITALExpressionEngine) position = (None, None) source_file = None def __init__(self, engine, contexts): self._engine = engine self.contexts = contexts self.setContext('nothing', None) self.setContext('default', _default) self.repeat_vars = rv = {} # Wrap this, as it is visible to restricted code self.setContext('repeat', rv) self.setContext('loop', rv) # alias self.vars = vars = contexts.copy() self._vars_stack = [vars] # Keep track of what needs to be popped as each scope ends. self._scope_stack = [] def setContext(self, name, value): # Hook to allow subclasses to do things like adding security proxies self.contexts[name] = value def beginScope(self): self.vars = vars = self.vars.copy() self._vars_stack.append(vars) self._scope_stack.append([]) def endScope(self): self._vars_stack.pop() self.vars = self._vars_stack[-1] scope = self._scope_stack.pop() # Pop repeat variables, if any i = len(scope) while i: i = i - 1 name, value = scope[i] if value is None: del self.repeat_vars[name] else: self.repeat_vars[name] = value def setLocal(self, name, value): self.vars[name] = value def setGlobal(self, name, value): for vars in self._vars_stack: vars[name] = value def getValue(self, name, default=None): value = default for vars in self._vars_stack: value = vars.get(name, default) if value is not default: break return value def setRepeat(self, name, expr): expr = self.evaluate(expr) if not expr: return self._engine.iteratorFactory(name, (), self) it = self._engine.iteratorFactory(name, expr, self) old_value = self.repeat_vars.get(name) self._scope_stack[-1].append((name, old_value)) self.repeat_vars[name] = it return it def evaluate(self, expression): if isinstance(expression, str): expression = self._engine.compile(expression) __traceback_supplement__ = ( TALESTracebackSupplement, self, expression) return expression(self) evaluateValue = evaluate def evaluateBoolean(self, expr): return not not self.evaluate(expr) def evaluateText(self, expr): text = self.evaluate(expr) if text is self.getDefault() or text is None: return text return unicode(text) def evaluateStructure(self, expr): return self.evaluate(expr) evaluateStructure = evaluate def evaluateMacro(self, expr): # TODO: Should return None or a macro definition return self.evaluate(expr) evaluateMacro = evaluate def createErrorInfo(self, err, position): return ErrorInfo(err, position) def getDefault(self): return _default def setSourceFile(self, source_file): self.source_file = source_file def setPosition(self, position): self.position = position class TALESTracebackSupplement(object): """Implementation of zope.exceptions.ITracebackSupplement""" def __init__(self, context, expression): self.context = context self.source_url = context.source_file self.line = context.position[0] self.column = context.position[1] self.expression = repr(expression) def getInfo(self, as_html=0): import pprint data = self.context.contexts.copy() if 'modules' in data: del data['modules'] # the list is really long and boring s = pprint.pformat(data) if not as_html: return ' - Names:\n %s' % s.replace('\n', '\n ') else: from cgi import escape return 'Names:
%s
' % (escape(s)) return None PKҾ4a0 zope/tales/pythonexpr.py############################################################################## # # Copyright (c) 2001, 2002 Zope Corporation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Generic Python Expression Handler $Id: pythonexpr.py 27081 2004-08-12 19:56:31Z srichter $ """ class PythonExpr(object): def __init__(self, name, expr, engine): text = '\n'.join(expr.splitlines()) # normalize line endings text = '(' + text + ')' # Put text in parens so newlines don't matter self.text = text try: code = self._compile(text, '') except SyntaxError, e: raise engine.getCompilerError()(str(e)) self._code = code self._varnames = code.co_names def _compile(self, text, filename): return compile(text, filename, 'eval') def _bind_used_names(self, econtext, builtins): # Bind template variables names = {} vars = econtext.vars marker = self if not isinstance(builtins, dict): builtins = builtins.__dict__ for vname in self._varnames: val = vars.get(vname, marker) if val is not marker: names[vname] = val elif vname not in builtins: # Fall back to using expression types as variable values. val = econtext._engine.getTypes().get(vname, marker) if val is not marker: val = ExprTypeProxy(vname, val, econtext) names[vname] = val names['__builtins__'] = builtins return names def __call__(self, econtext): __traceback_info__ = self.text vars = self._bind_used_names(econtext, __builtins__) return eval(self._code, vars) def __str__(self): return 'Python expression "%s"' % self.text def __repr__(self): return '' % self.text class ExprTypeProxy(object): '''Class that proxies access to an expression type handler''' def __init__(self, name, handler, econtext): self._name = name self._handler = handler self._econtext = econtext def __call__(self, text): return self._handler(self._name, text, self._econtext._engine)(self._econtext) PKҾ4ǖ9''zope/tales/expressions.py############################################################################## # # Copyright (c) 2001, 2002 Zope Corporation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Basic Page Template expression types. $Id: expressions.py 27079 2004-08-12 19:45:55Z srichter $ """ import re from zope.interface import implements from zope.tales.tales import _valid_name, _parse_expr, NAME_RE, Undefined from zope.tales.interfaces import ITALESExpression, ITALESFunctionNamespace Undefs = (Undefined, AttributeError, KeyError, TypeError, IndexError) _marker = object() namespace_re = re.compile('(\w+):(.+)') def simpleTraverse(object, path_items, econtext): """Traverses a sequence of names, first trying attributes then items. """ for name in path_items: next = getattr(object, name, _marker) if next is not _marker: object = next elif hasattr(object, '__getitem__'): object = object[name] else: raise NameError, name return object class SubPathExpr(object): def __init__(self, path, traverser, engine): self._traverser = traverser self._engine = engine # Parse path compiledpath = [] currentpath = [] for element in str(path).strip().split('/'): if not element: raise engine.getCompilerError()( 'Path element may not be empty in %r' % path) if element.startswith('?'): if currentpath: compiledpath.append(tuple(currentpath)) currentpath = [] if not _valid_name(element[1:]): raise engine.getCompilerError()( 'Invalid variable name "%s"' % element[1:]) compiledpath.append(element[1:]) else: match = namespace_re.match(element) if match: if currentpath: compiledpath.append(tuple(currentpath)) currentpath = [] namespace, functionname = match.groups() if not _valid_name(namespace): raise engine.getCompilerError()( 'Invalid namespace name "%s"' % namespace) if not _valid_name(functionname): raise engine.getCompilerError()( 'Invalid function name "%s"' % functionname) try: compiledpath.append( self._engine.getFunctionNamespace(namespace)) except KeyError: raise engine.getCompilerError()( 'Unknown namespace "%s"' % namespace) currentpath.append(functionname) else: currentpath.append(element) if currentpath: compiledpath.append(tuple(currentpath)) first = compiledpath[0] base = first[0] if callable(first): # check for initial function raise engine.getCompilerError()( 'Namespace function specified in first subpath element') elif isinstance(first, basestring): # check for initial ? raise engine.getCompilerError()( 'Dynamic name specified in first subpath element') if base and not _valid_name(base): raise engine.getCompilerError()( 'Invalid variable name "%s"' % element) self._base = base compiledpath[0] = first[1:] self._compiled_path = tuple(compiledpath) def _eval(self, econtext, isinstance=isinstance): vars = econtext.vars compiled_path = self._compiled_path base = self._base if base == 'CONTEXTS' or not base: # Special base name ob = econtext.contexts else: ob = vars[base] if isinstance(ob, DeferWrapper): ob = ob() for element in compiled_path: if isinstance(element, tuple): ob = self._traverser(ob, element, econtext) elif isinstance(element, basestring): val = vars[element] # If the value isn't a string, assume it's a sequence # of path names. if isinstance(val, basestring): val = (val,) ob = self._traverser(ob, val, econtext) elif callable(element): ob = element(ob) # TODO: Once we have n-ary adapters, use them. if ITALESFunctionNamespace.providedBy(ob): ob.setEngine(econtext) else: raise "Waagh!" return ob class PathExpr(object): """One or more subpath expressions, separated by '|'.""" implements(ITALESExpression) # _default_type_names contains the expression type names this # class is usually registered for. _default_type_names = ( 'standard', 'path', 'exists', 'nocall', ) def __init__(self, name, expr, engine, traverser=simpleTraverse): self._s = expr self._name = name paths = expr.split('|') self._subexprs = [] add = self._subexprs.append for i in range(len(paths)): path = paths[i].lstrip() if _parse_expr(path): # This part is the start of another expression type, # so glue it back together and compile it. add(engine.compile('|'.join(paths[i:]).lstrip())) break add(SubPathExpr(path, traverser, engine)._eval) def _exists(self, econtext): for expr in self._subexprs: try: expr(econtext) except Undefs: pass else: return 1 return 0 def _eval(self, econtext): for expr in self._subexprs[:-1]: # Try all but the last subexpression, skipping undefined ones. try: ob = expr(econtext) except Undefs: pass else: break else: # On the last subexpression allow exceptions through. ob = self._subexprs[-1](econtext) if self._name == 'nocall': return ob # Call the object if it is callable. if hasattr(ob, '__call__'): return ob() return ob def __call__(self, econtext): if self._name == 'exists': return self._exists(econtext) return self._eval(econtext) def __str__(self): return '%s expression (%s)' % (self._name, `self._s`) def __repr__(self): return '' % (self._name, `self._s`) _interp = re.compile(r'\$(%(n)s)|\${(%(n)s(?:/[^}]*)*)}' % {'n': NAME_RE}) class StringExpr(object): implements(ITALESExpression) def __init__(self, name, expr, engine): self._s = expr if '%' in expr: expr = expr.replace('%', '%%') self._vars = vars = [] if '$' in expr: # Use whatever expr type is registered as "path". path_type = engine.getTypes()['path'] parts = [] for exp in expr.split('$$'): if parts: parts.append('$') m = _interp.search(exp) while m is not None: parts.append(exp[:m.start()]) parts.append('%s') vars.append(path_type( 'path', m.group(1) or m.group(2), engine)) exp = exp[m.end():] m = _interp.search(exp) if '$' in exp: raise engine.getCompilerError()( '$ must be doubled or followed by a simple path') parts.append(exp) expr = ''.join(parts) self._expr = expr def __call__(self, econtext): vvals = [] for var in self._vars: v = var(econtext) vvals.append(v) return self._expr % tuple(vvals) def __str__(self): return 'string expression (%s)' % `self._s` def __repr__(self): return '' % `self._s` class NotExpr(object): implements(ITALESExpression) def __init__(self, name, expr, engine): self._s = expr = expr.lstrip() self._c = engine.compile(expr) def __call__(self, econtext): return int(not econtext.evaluateBoolean(self._c)) def __repr__(self): return '' % `self._s` class DeferWrapper(object): def __init__(self, expr, econtext): self._expr = expr self._econtext = econtext def __str__(self): return str(self()) def __call__(self): return self._expr(self._econtext) class DeferExpr(object): implements(ITALESExpression) def __init__(self, name, expr, compiler): self._s = expr = expr.lstrip() self._c = compiler.compile(expr) def __call__(self, econtext): return DeferWrapper(self._c, econtext) def __repr__(self): return '' % `self._s` class SimpleModuleImporter(object): """Minimal module importer with no security.""" def __getitem__(self, module): mod = self._get_toplevel_module(module) path = module.split('.') for name in path[1:]: mod = getattr(mod, name) return mod def _get_toplevel_module(self, module): # This can be overridden to add security proxies. return __import__(module) PKҾ4Ɗt t zope/tales/interfaces.py############################################################################## # # Copyright (c) 2003 Zope Corporation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Interface that describes the 'macros' attribute of a PageTemplate. $Id: interfaces.py 25177 2004-06-02 13:17:31Z jim $ """ from zope.interface import Interface try: from zope import tal except ImportError: tal = None class ITALESFunctionNamespace(Interface): """Function namespaces can be used in TALES path expressions to extract information in non-default ways.""" def setEngine(engine): """Sets the engine that is used to evaluate TALES expressions.""" class ITALESExpression(Interface): """TALES expression These are expression handlers that handle a specific type of expression in TALES, e.g. path or string expression. """ def __call__(econtext): """Evaluate expression according to the given execution context 'econtext' and return computed value. """ if tal is not None: from zope.tal.interfaces import ITALIterator class ITALESIterator(ITALIterator): """TAL Iterator provided by TALES Values of this iterator are assigned to items in the repeat namespace. For example, with a TAL statement like: tal:repeat="item items", an iterator will be assigned to "repeat/item". The iterator provides a number of handy methods useful in writing TAL loops. The results are undefined of calling any of the methods except 'length' before the first iteration. """ def index(): """Return the position (starting with "0") within the iteration """ def number(): """Return the position (starting with "1") within the iteration """ def even(): """Return whether the current position is even """ def odd(): """Return whether the current position is odd """ def start(): """Return whether the current position is the first position """ def end(): """Return whether the current position is the last position """ def letter(): """Return the position (starting with "a") within the iteration """ def Letter(): """Return the position (starting with "A") within the iteration """ def roman(): """Return the position (starting with "i") within the iteration """ def Roman(): """Return the position (starting with "I") within the iteration """ def item(): """Return the item at the current position """ def length(): """Return whether the length of the sequence Note that this may fail if the TAL iterator was created on a Python iterator. """ PKҾ4iYcczope/tales/engine.py############################################################################## # # Copyright (c) 2002 Zope Corporation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Expression engine configuration and registration. Each expression engine can have its own expression types and base names. $Id: engine.py 25177 2004-06-02 13:17:31Z jim $ """ from zope.tales.tales import ExpressionEngine from zope.tales.expressions import PathExpr, StringExpr, NotExpr, DeferExpr from zope.tales.expressions import SimpleModuleImporter from zope.tales.pythonexpr import PythonExpr def Engine(): e = ExpressionEngine() reg = e.registerType for pt in PathExpr._default_type_names: reg(pt, PathExpr) reg('string', StringExpr) reg('python', PythonExpr) reg('not', NotExpr) reg('defer', DeferExpr) e.registerBaseName('modules', SimpleModuleImporter()) return e Engine = Engine() PKҾ4hAE%%zope/tales/DEPENDENCIES.cfgzope.interface zope.tal zope.testing PKm4(zope/tales/__init__.pyc; }?3Dc@s dZdS(seTemplate Attribute Language - Expression Syntax $Id: __init__.py 27165 2004-08-17 11:20:31Z hdima $ N(s__doc__(((s1build/bdist.linux-i686/egg/zope/tales/__init__.pys?sPKm4JAmmzope/tales/tales.pyc; }?3Dc@sdZdkZdklZydklZWnej o eZnXeo8dkl Z dkl Z dkl Z dk l Z ndZeid eiZeid eiZd efd YZd efdYZdefdYZdefdYZeZdefdYZdefdYZdefdYZdefdYZdefdYZdS(siTALES An implementation of a TAL expression engine $Id: tales.py 27081 2004-08-12 19:56:31Z srichter $ N(s implements(stal(sITALExpressionEngine(sITALExpressionCompiler(sITALExpressionErrorInfo(sITALESIterators[a-zA-Z][a-zA-Z0-9_]*s(%s):s%s$s TALESErrorcBstZdZRS(sError during TALES evaluation(s__name__s __module__s__doc__(((s.build/bdist.linux-i686/egg/zope/tales/tales.pys TALESError)s s UndefinedcBstZdZRS(s2Exception raised on traversal of an undefined path(s__name__s __module__s__doc__(((s.build/bdist.linux-i686/egg/zope/tales/tales.pys Undefined,s s CompilerErrorcBstZdZRS(sTALES Compiler Error(s__name__s __module__s__doc__(((s.build/bdist.linux-i686/egg/zope/tales/tales.pys CompilerError/s sRegistrationErrorcBstZdZRS(s/Expression type or base name registration Error(s__name__s __module__s__doc__(((s.build/bdist.linux-i686/egg/zope/tales/tales.pysRegistrationError2s sIteratorcBs.tZdZeoeendZdZdZdZ dZ dZ dZ e dd d Zd Zd d fddfddfddfddfddfddfddfddfddfd d!fd"d#fd$d%ff d&Zd'Zd(Zd)Zd*Zd+ZRS(,sTALES Iterator cCs||_t||_}d|_||_|i |_ t |_ y|i|_Wntj ot|_n Xt |_dS(suConstruct an iterator Iterators are defined for a name, a sequence, or an iterator and a context, where a context simply has a setLocal method: >>> context = Context(ExpressionEngine(), {}) >>> it = Iterator('foo', ("apple", "pear", "orange"), context) A local variable is not set until the iterator is used: >>> int("foo" in context.vars) 0 We can create an iterator on an empty sequence: >>> it = Iterator('foo', (), context) An iterator works as well: >>> it = Iterator('foo', {"apple":1, "pear":1, "orange":1}, context) >>> it.next() True >>> it = Iterator('foo', {}, context) >>> it.next() False >>> it = Iterator('foo', iter((1, 2, 3)), context) >>> it.next() True >>> it.next() True iN(sseqsselfs_seqsiters_itersis _nextIndexsnames_namescontextssetLocals _setLocalsFalses_lastsnexts_nexts StopIterationsTrues_done(sselfsnamesseqscontextsi((s.build/bdist.linux-i686/egg/zope/tales/tales.pys__init__?s"     cCs|iotSn|i|_}y|ii|_Wn%tj ot |_t |_ nX|i d7_ |i |i |t SdS(sAdvance the iterator, if possible. >>> context = Context(ExpressionEngine(), {}) >>> it = Iterator('foo', ("apple", "pear", "orange"), context) >>> bool(it.next()) True >>> context.vars['foo'] 'apple' >>> bool(it.next()) True >>> context.vars['foo'] 'pear' >>> bool(it.next()) True >>> context.vars['foo'] 'orange' >>> bool(it.next()) False >>> it = Iterator('foo', {"apple":1, "pear":1, "orange":1}, context) >>> bool(it.next()) True >>> bool(it.next()) True >>> bool(it.next()) True >>> bool(it.next()) False >>> it = Iterator('foo', (), context) >>> bool(it.next()) False >>> it = Iterator('foo', {}, context) >>> bool(it.next()) False If we can advance, set a local variable to the new value. iN(sselfs_donesFalses_nexts_itemsvs_itersnexts StopIterationsTrues_lasts _nextIndexs _setLocals_name(sselfsv((s.build/bdist.linux-i686/egg/zope/tales/tales.pysnextss(  cCs2|id}|djotdn|SdS(sGet the iterator index >>> context = Context(ExpressionEngine(), {}) >>> it = Iterator('foo', ("apple", "pear", "orange"), context) >>> int(bool(it.next())) 1 >>> it.index() 0 >>> int(bool(it.next())) 1 >>> it.index() 1 >>> int(bool(it.next())) 1 >>> it.index() 2 iisNo iteration positionN(sselfs _nextIndexsindexs TypeError(sselfsindex((s.build/bdist.linux-i686/egg/zope/tales/tales.pysindexs   cCs |iSdS(sGet the iterator position >>> context = Context(ExpressionEngine(), {}) >>> it = Iterator('foo', ("apple", "pear", "orange"), context) >>> int(bool(it.next())) 1 >>> it.number() 1 >>> int(bool(it.next())) 1 >>> it.number() 2 >>> int(bool(it.next())) 1 >>> it.number() 3 N(sselfs _nextIndex(sself((s.build/bdist.linux-i686/egg/zope/tales/tales.pysnumberscCs|id SdS(s|Test whether the position is even >>> context = Context(ExpressionEngine(), {}) >>> it = Iterator('foo', ("apple", "pear", "orange"), context) >>> it.next() True >>> it.even() False >>> it.next() True >>> it.even() True >>> it.next() True >>> it.even() False iN(sselfs _nextIndex(sself((s.build/bdist.linux-i686/egg/zope/tales/tales.pysevenscCst|idSdS(swTest whether the position is odd >>> context = Context(ExpressionEngine(), {}) >>> it = Iterator('foo', ("apple", "pear", "orange"), context) >>> it.next() True >>> it.odd() True >>> it.next() True >>> it.odd() False >>> it.next() True >>> it.odd() True iN(sboolsselfs _nextIndex(sself((s.build/bdist.linux-i686/egg/zope/tales/tales.pysoddscCs|idodSndSdS(sReturn 'odd' or 'even' depending on the position's parity >>> context = Context(ExpressionEngine(), {}) >>> it = Iterator('foo', ("apple", "pear", "orange"), context) >>> it.next() True >>> it.parity() 'odd' >>> it.next() True >>> it.parity() 'even' >>> it.next() True >>> it.parity() 'odd' isoddsevenN(sselfs _nextIndex(sself((s.build/bdist.linux-i686/egg/zope/tales/tales.pysparityssaicCs||id}|djotdnd}xEno=t||\}}t|||}| o|Sq3q:WdS(sGet the iterator position as a lower-case letter >>> context = Context(ExpressionEngine(), {}) >>> it = Iterator('foo', ("apple", "pear", "orange"), context) >>> it.next() True >>> it.letter() 'a' >>> it.next() True >>> it.letter() 'b' >>> it.next() True >>> it.letter() 'c' iisNo iteration positionsN( sselfs _nextIndexsindexs TypeErrorsssdivmodsradixsoffschrsbase(sselfsbasesradixsindexsoffss((s.build/bdist.linux-i686/egg/zope/tales/tales.pysletters  cCs|idtdSdS(sGet the iterator position as an upper-case letter >>> context = Context(ExpressionEngine(), {}) >>> it = Iterator('foo', ("apple", "pear", "orange"), context) >>> it.next() True >>> it.Letter() 'A' >>> it.next() True >>> it.Letter() 'B' >>> it.next() True >>> it.Letter() 'C' sbasesAN(sselfslettersord(sself((s.build/bdist.linux-i686/egg/zope/tales/tales.pysLetter.sisMisCMisDisCDidsCiZsXCi2sLi(sXLi sXi sIXisVisIVisIcCsQ|i}d}x7|D]/\}}t||\}}|||}qW|SdS(sGet the iterator position as an upper-case roman numeral >>> context = Context(ExpressionEngine(), {}) >>> it = Iterator('foo', ("apple", "pear", "orange"), context) >>> it.next() True >>> it.Roman() 'I' >>> it.next() True >>> it.Roman() 'II' >>> it.next() True >>> it.Roman() 'III' sN( sselfs _nextIndexsnsssrnvaluessvsrsdivmodsrct(sselfsrnvaluessrctsnsssrsv((s.build/bdist.linux-i686/egg/zope/tales/tales.pysRomanBs  cCs|iiSdS(sGet the iterator position as a lower-case roman numeral >>> context = Context(ExpressionEngine(), {}) >>> it = Iterator('foo', ("apple", "pear", "orange"), context) >>> it.next() True >>> it.roman() 'i' >>> it.next() True >>> it.roman() 'ii' >>> it.next() True >>> it.roman() 'iii' N(sselfsRomanslower(sself((s.build/bdist.linux-i686/egg/zope/tales/tales.pysroman^scCs|idjSdS(s*Test whether the position is the first position >>> context = Context(ExpressionEngine(), {}) >>> it = Iterator('foo', ("apple", "pear", "orange"), context) >>> it.next() True >>> it.start() True >>> it.next() True >>> it.start() False >>> it.next() True >>> it.start() False >>> it = Iterator('foo', {}, context) >>> it.start() False >>> it.next() False >>> it.start() False iN(sselfs _nextIndex(sself((s.build/bdist.linux-i686/egg/zope/tales/tales.pysstartrscCs |iSdS(sTest whether the position is the last position >>> context = Context(ExpressionEngine(), {}) >>> it = Iterator('foo', ("apple", "pear", "orange"), context) >>> it.next() True >>> it.end() False >>> it.next() True >>> it.end() False >>> it.next() True >>> it.end() True >>> it = Iterator('foo', {}, context) >>> it.end() False >>> it.next() False >>> it.end() False N(sselfs_last(sself((s.build/bdist.linux-i686/egg/zope/tales/tales.pysendscCs+|idjotdn|iSdS(sGet the iterator value >>> context = Context(ExpressionEngine(), {}) >>> it = Iterator('foo', ("apple", "pear", "orange"), context) >>> it.next() True >>> it.item() 'apple' >>> it.next() True >>> it.item() 'pear' >>> it.next() True >>> it.item() 'orange' >>> it = Iterator('foo', {1:2}, context) >>> it.next() True >>> it.item() 1 isNo iteration positionN(sselfs _nextIndexs TypeErrors_item(sself((s.build/bdist.linux-i686/egg/zope/tales/tales.pysitemscCst|iSdS(sGet the length of the iterator sequence >>> context = Context(ExpressionEngine(), {}) >>> it = Iterator('foo', ("apple", "pear", "orange"), context) >>> it.length() 3 You can even get the length of a mapping: >>> it = Iterator('foo', {"apple":1, "pear":2, "orange":3}, context) >>> it.length() 3 But you can't get the length of an iterable which doesn't support len(): >>> class MyIter(object): ... def __init__(self, seq): ... self._next = iter(seq).next ... def __iter__(self): ... return self ... def next(self): ... return self._next() >>> it = Iterator('foo', MyIter({"apple":1, "pear":2}), context) >>> it.length() Traceback (most recent call last): ... TypeError: len() of unsized object N(slensselfs_seq(sself((s.build/bdist.linux-i686/egg/zope/tales/tales.pyslengths(s__name__s __module__s__doc__stals implementssITALESIterators__init__snextsindexsnumbersevensoddsparitysordslettersLettersRomansromansstartsendsitemslength(((s.build/bdist.linux-i686/egg/zope/tales/tales.pysIterator8s$  4 7          s ErrorInfocBs5tZdZeoeeneefdZRS(s=Information about an exception passed to an on-error handler.cCsYt|to|i|_||_n||_t|_|d|_ |d|_ dS(Nii( s isinstanceserrs Exceptions __class__sselfstypesvaluesNonespositionslinenosoffset(sselfserrsposition((s.build/bdist.linux-i686/egg/zope/tales/tales.pys__init__s     (s__name__s __module__s__doc__stals implementssITALExpressionErrorInfosNones__init__(((s.build/bdist.linux-i686/egg/zope/tales/tales.pys ErrorInfos sExpressionEnginecBstZdZeoeendZdZdZdZ dZ dZ dZ dZ ed Zd ZRS( s+Expression Engine An instance of this class keeps a mutable collection of expression type handlers. It can compile expression strings by delegating to these handlers. It can provide an expression Context, which is capable of holding state and evaluating compiled expressions. cCs(h|_h|_h|_t|_dS(N(sselfstypess base_namess namespacessIteratorsiteratorFactory(sself((s.build/bdist.linux-i686/egg/zope/tales/tales.pys__init__s   cCs||i|Names:
%s
( spprintsselfscontextscontextsscopysdataspformatsssas_htmlsreplacescgisescapesNone(sselfsas_htmlspprintsssescapesdata((s.build/bdist.linux-i686/egg/zope/tales/tales.pysgetInfos    (s__name__s __module__s__doc__s__init__sgetInfo(((s.build/bdist.linux-i686/egg/zope/tales/tales.pysTALESTracebackSupplements  (s__doc__sreszope.interfaces implementsszopestals ImportErrorsNoneszope.tal.interfacessITALExpressionEnginesITALExpressionCompilersITALExpressionErrorInfoszope.tales.interfacessITALESIteratorsNAME_REscompilesmatchs _parse_exprs _valid_names Exceptions TALESErrors Undefineds CompilerErrorsRegistrationErrorsobjects_defaultsIterators ErrorInfosExpressionEnginesContextsTALESTracebackSupplement(sContextsITALESIteratorstals _parse_exprs _valid_namesresRegistrationErrorsITALExpressionErrorInfos_defaultsTALESTracebackSupplements Undefineds CompilerErrorsITALExpressionCompilers implementssIteratorsNAME_REsITALExpressionEnginesExpressionEngines TALESErrors ErrorInfo((s.build/bdist.linux-i686/egg/zope/tales/tales.pys?s2       mwPKm4̼nzope/tales/pythonexpr.pyc; }?3Dc@s6dZdefdYZdefdYZdS(s\Generic Python Expression Handler $Id: pythonexpr.py 27081 2004-08-12 19:56:31Z srichter $ s PythonExprcBs>tZdZdZdZdZdZdZRS(NcCsdi|i}d|d}||_y|i|d}Wn-tj o!}|i t |nX||_ |i |_dS(Ns s(s)s(sjoinsexprs splitlinesstextsselfs_compilescodes SyntaxErrorsesenginesgetCompilerErrorsstrs_codesco_namess _varnames(sselfsnamesexprsenginescodesestext((s3build/bdist.linux-i686/egg/zope/tales/pythonexpr.pys__init__s  cCst||dSdS(Nseval(scompilestextsfilename(sselfstextsfilename((s3build/bdist.linux-i686/egg/zope/tales/pythonexpr.pys_compilescCsh}|i}|}t|t o |i}nx|i D]}|i ||}||j o|||(sselfstext(sself((s3build/bdist.linux-i686/egg/zope/tales/pythonexpr.pys__repr__?s(s__name__s __module__s__init__s_compiles_bind_used_namess__call__s__str__s__repr__(((s3build/bdist.linux-i686/egg/zope/tales/pythonexpr.pys PythonExprs     s ExprTypeProxycBs tZdZdZdZRS(s7Class that proxies access to an expression type handlercCs||_||_||_dS(N(snamesselfs_nameshandlers_handlersecontexts _econtext(sselfsnameshandlersecontext((s3build/bdist.linux-i686/egg/zope/tales/pythonexpr.pys__init__Es  cCs)|i|i||ii|iSdS(N(sselfs_handlers_namestexts _econtexts_engine(sselfstext((s3build/bdist.linux-i686/egg/zope/tales/pythonexpr.pys__call__Js(s__name__s __module__s__doc__s__init__s__call__(((s3build/bdist.linux-i686/egg/zope/tales/pythonexpr.pys ExprTypeProxyCs  N(s__doc__sobjects PythonExprs ExprTypeProxy(s PythonExprs ExprTypeProxy((s3build/bdist.linux-i686/egg/zope/tales/pythonexpr.pys?s0PKm4/)4)4zope/tales/expressions.pyc; }?3Dc@s>dZdkZdklZdklZlZlZlZdk l Z l Z ee e eefZeZeidZdZdefdYZd efd YZeid hd e<Zd efdYZdefdYZdefdYZdefdYZdefdYZdS(saBasic Page Template expression types. $Id: expressions.py 27079 2004-08-12 19:45:55Z srichter $ N(s implements(s _valid_names _parse_exprsNAME_REs Undefined(sITALESExpressionsITALESFunctionNamespaces (\w+):(.+)cCsix^|D]V}t||t}|tj o |}qt|do||}qt|qW|SdS(sGTraverses a sequence of names, first trying attributes then items. s __getitem__N(s path_itemssnamesgetattrsobjects_markersnextshasattrs NameError(sobjects path_itemssecontextsnamesnext((s4build/bdist.linux-i686/egg/zope/tales/expressions.pyssimpleTraverses   s SubPathExprcBstZdZedZRS(Nc Cs||_||_g}g}xt|i i dD]}| o|i d|n|i doi|o|it|g}nt|d o|i d|dn|i|dq:ti|} | o|o|it|g}n| i\}} t| o|i d|nt|  o|i d| ny|i|ii|Wn)tj o|i d|nX|i| q:|i|q:W|o|it|n|d }|d } t|o|i d n't|to|i d n| o t|  o|i d|n| |_|d|d (sselfs_names_s(sself((s4build/bdist.linux-i686/egg/zope/tales/expressions.pys__repr__s( s__name__s __module__s__doc__s implementssITALESExpressions_default_type_namesssimpleTraverses__init__s_existss_evals__call__s__str__s__repr__(((s4build/bdist.linux-i686/egg/zope/tales/expressions.pysPathExprs      s \$(%(n)s)|\${(%(n)s(?:/[^}]*)*)}sns StringExprcBs6tZeedZdZdZdZRS(Nc Csw||_d|jo|idd}ng|_}d|jo$|id}g}x|i dD]}|o|i dnt i|}x|tj oy|i ||i |i d|i |d|idp |id|||i}t i|}qWd|jo|id n|i |qlWd i|}n||_dS( Ns%s%%s$spaths$$s%siis.$ must be doubled or followed by a simple paths(sexprsselfs_ssreplaces_varssvarssenginesgetTypess path_typespartsssplitsexpsappends_interpssearchsmsNonesstartsgroupsendsgetCompilerErrorsjoins_expr( sselfsnamesexprsenginesvarssmspartssexps path_type((s4build/bdist.linux-i686/egg/zope/tales/expressions.pys__init__s0      2 cCsHg}x*|iD]}||}|i|qW|it|SdS(N( svvalssselfs_varssvarsecontextsvsappends_exprstuple(sselfsecontextsvvalssvsvar((s4build/bdist.linux-i686/egg/zope/tales/expressions.pys__call__s   cCsd|i SdS(Nsstring expression (%s)(sselfs_s(sself((s4build/bdist.linux-i686/egg/zope/tales/expressions.pys__str__scCsd|i SdS(Ns(sselfs_s(sself((s4build/bdist.linux-i686/egg/zope/tales/expressions.pys__repr__s(s__name__s __module__s implementssITALESExpressions__init__s__call__s__str__s__repr__(((s4build/bdist.linux-i686/egg/zope/tales/expressions.pys StringExprs     sNotExprcBs-tZeedZdZdZRS(NcCs)|i|_}|i||_dS(N(sexprslstripsselfs_ssenginescompiles_c(sselfsnamesexprsengine((s4build/bdist.linux-i686/egg/zope/tales/expressions.pys__init__ scCst|i|i SdS(N(sintsecontextsevaluateBooleansselfs_c(sselfsecontext((s4build/bdist.linux-i686/egg/zope/tales/expressions.pys__call__ scCsd|i SdS(Ns (sselfs_s(sself((s4build/bdist.linux-i686/egg/zope/tales/expressions.pys__repr__s(s__name__s __module__s implementssITALESExpressions__init__s__call__s__repr__(((s4build/bdist.linux-i686/egg/zope/tales/expressions.pysNotExprs   s DeferWrappercBs#tZdZdZdZRS(NcCs||_||_dS(N(sexprsselfs_exprsecontexts _econtext(sselfsexprsecontext((s4build/bdist.linux-i686/egg/zope/tales/expressions.pys__init__s cCst|SdS(N(sstrsself(sself((s4build/bdist.linux-i686/egg/zope/tales/expressions.pys__str__scCs|i|iSdS(N(sselfs_exprs _econtext(sself((s4build/bdist.linux-i686/egg/zope/tales/expressions.pys__call__s(s__name__s __module__s__init__s__str__s__call__(((s4build/bdist.linux-i686/egg/zope/tales/expressions.pys DeferWrappers  s DeferExprcBs-tZeedZdZdZRS(NcCs)|i|_}|i||_dS(N(sexprslstripsselfs_sscompilerscompiles_c(sselfsnamesexprscompiler((s4build/bdist.linux-i686/egg/zope/tales/expressions.pys__init__#scCst|i|SdS(N(s DeferWrappersselfs_csecontext(sselfsecontext((s4build/bdist.linux-i686/egg/zope/tales/expressions.pys__call__'scCsd|i SdS(Ns(sselfs_s(sself((s4build/bdist.linux-i686/egg/zope/tales/expressions.pys__repr__*s(s__name__s __module__s implementssITALESExpressions__init__s__call__s__repr__(((s4build/bdist.linux-i686/egg/zope/tales/expressions.pys DeferExpr s   sSimpleModuleImportercBs tZdZdZdZRS(s)Minimal module importer with no security.cCsJ|i|}|id}x!|dD]}t||}q)W|SdS(Ns.i(sselfs_get_toplevel_modulesmodulesmodssplitspathsnamesgetattr(sselfsmodulesnamespathsmod((s4build/bdist.linux-i686/egg/zope/tales/expressions.pys __getitem__1s  cCst|SdS(N(s __import__smodule(sselfsmodule((s4build/bdist.linux-i686/egg/zope/tales/expressions.pys_get_toplevel_module8s(s__name__s __module__s__doc__s __getitem__s_get_toplevel_module(((s4build/bdist.linux-i686/egg/zope/tales/expressions.pysSimpleModuleImporter.s  (s__doc__sreszope.interfaces implementsszope.tales.taless _valid_names _parse_exprsNAME_REs Undefinedszope.tales.interfacessITALESExpressionsITALESFunctionNamespacesAttributeErrorsKeyErrors TypeErrors IndexErrorsUndefssobjects_markerscompiles namespace_ressimpleTraverses SubPathExprsPathExprs_interps StringExprsNotExprs DeferWrappers DeferExprsSimpleModuleImporter(s_interps namespace_res DeferExprs _parse_exprs _valid_namesres StringExprssimpleTraverses SubPathExprs_markers UndefinedsSimpleModuleImportersPathExprs implementssNotExprsUndefss DeferWrappersITALESFunctionNamespacesNAME_REsITALESExpression((s4build/bdist.linux-i686/egg/zope/tales/expressions.pys?s     eH+ PKm4U$//zope/tales/interfaces.pyc; }?3Dc@sdZdklZydklZWnej o eZnXdefdYZdefdYZeej o'dk l Z de fd YZ nd S( sxInterface that describes the 'macros' attribute of a PageTemplate. $Id: interfaces.py 25177 2004-06-02 13:17:31Z jim $ (s Interface(stalsITALESFunctionNamespacecBstZdZdZRS(siFunction namespaces can be used in TALES path expressions to extract information in non-default ways.cCsdS(s;Sets the engine that is used to evaluate TALES expressions.N((sengine((s3build/bdist.linux-i686/egg/zope/tales/interfaces.pys setEngines(s__name__s __module__s__doc__s setEngine(((s3build/bdist.linux-i686/egg/zope/tales/interfaces.pysITALESFunctionNamespaces sITALESExpressioncBstZdZdZRS(sTALES expression These are expression handlers that handle a specific type of expression in TALES, e.g. path or string expression. cCsdS(ssEvaluate expression according to the given execution context 'econtext' and return computed value. N((secontext((s3build/bdist.linux-i686/egg/zope/tales/interfaces.pys__call__(s(s__name__s __module__s__doc__s__call__(((s3build/bdist.linux-i686/egg/zope/tales/interfaces.pysITALESExpression!s (s ITALIteratorsITALESIteratorcBsztZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d ZRS( sTAL Iterator provided by TALES Values of this iterator are assigned to items in the repeat namespace. For example, with a TAL statement like: tal:repeat="item items", an iterator will be assigned to "repeat/item". The iterator provides a number of handy methods useful in writing TAL loops. The results are undefined of calling any of the methods except 'length' before the first iteration. cCsdS(sIReturn the position (starting with "0") within the iteration N((((s3build/bdist.linux-i686/egg/zope/tales/interfaces.pysindex=scCsdS(sIReturn the position (starting with "1") within the iteration N((((s3build/bdist.linux-i686/egg/zope/tales/interfaces.pysnumberAscCsdS(s8Return whether the current position is even N((((s3build/bdist.linux-i686/egg/zope/tales/interfaces.pysevenEscCsdS(s7Return whether the current position is odd N((((s3build/bdist.linux-i686/egg/zope/tales/interfaces.pysoddIscCsdS(sFReturn whether the current position is the first position N((((s3build/bdist.linux-i686/egg/zope/tales/interfaces.pysstartMscCsdS(sEReturn whether the current position is the last position N((((s3build/bdist.linux-i686/egg/zope/tales/interfaces.pysendQscCsdS(sIReturn the position (starting with "a") within the iteration N((((s3build/bdist.linux-i686/egg/zope/tales/interfaces.pysletterUscCsdS(sIReturn the position (starting with "A") within the iteration N((((s3build/bdist.linux-i686/egg/zope/tales/interfaces.pysLetterYscCsdS(sIReturn the position (starting with "i") within the iteration N((((s3build/bdist.linux-i686/egg/zope/tales/interfaces.pysroman]scCsdS(sIReturn the position (starting with "I") within the iteration N((((s3build/bdist.linux-i686/egg/zope/tales/interfaces.pysRomanascCsdS(s4Return the item at the current position N((((s3build/bdist.linux-i686/egg/zope/tales/interfaces.pysitemescCsdS(sReturn whether the length of the sequence Note that this may fail if the TAL iterator was created on a Python iterator. N((((s3build/bdist.linux-i686/egg/zope/tales/interfaces.pyslengthis(s__name__s __module__s__doc__sindexsnumbersevensoddsstartsendslettersLettersromansRomansitemslength(((s3build/bdist.linux-i686/egg/zope/tales/interfaces.pysITALESIterator0s            N( s__doc__szope.interfaces Interfaceszopestals ImportErrorsNonesITALESFunctionNamespacesITALESExpressionszope.tal.interfacess ITALIteratorsITALESIterator(sITALESIteratorsITALESFunctionNamespacestals InterfacesITALESExpressions ITALIterator((s3build/bdist.linux-i686/egg/zope/tales/interfaces.pys?s    PKm4քzope/tales/engine.pyc; }?3Dc@sbdZdklZdklZlZlZlZdklZdk l Z dZ e Z dS(sExpression engine configuration and registration. Each expression engine can have its own expression types and base names. $Id: engine.py 25177 2004-06-02 13:17:31Z jim $ (sExpressionEngine(sPathExprs StringExprsNotExprs DeferExpr(sSimpleModuleImporter(s PythonExprcCst}|i}xtiD]}||tqW|dt|dt|dt |dt |i dt |SdS(Nsstringspythonsnotsdefersmodules( sExpressionEngineses registerTypesregsPathExprs_default_type_namesspts StringExprs PythonExprsNotExprs DeferExprsregisterBaseNamesSimpleModuleImporter(sesptsreg((s/build/bdist.linux-i686/egg/zope/tales/engine.pysEngines       N( s__doc__szope.tales.talessExpressionEngineszope.tales.expressionssPathExprs StringExprsNotExprs DeferExprsSimpleModuleImporterszope.tales.pythonexprs PythonExprsEngine(sEnginesNotExprsSimpleModuleImporters DeferExprs StringExprs PythonExprsExpressionEnginesPathExpr((s/build/bdist.linux-i686/egg/zope/tales/engine.pys?s     PKm4EGG-INFO/requires.txtzope.interface zope.talPKm4,x66EGG-INFO/PKG-INFOMetadata-Version: 1.0 Name: zope.tales Version: 3.0.0 Summary: Zope 3 Template Application Language Expression Syntax (TALES) Home-page: http://svn.zope.org/zope.tales/tags/3.0.0 Author: Zope Corporation and Contributors Author-email: zope3-dev@zope.org License: ZPL 2.1 Description: UNKNOWN Platform: UNKNOWN PK1m4EGG-INFO/not-zip-safePKm4EGG-INFO/top_level.txtzope PKm4EGG-INFO/namespace_packages.txtzope PKm4\6EGG-INFO/SOURCES.txtCHANGES.txt INSTALL.txt README.txt develop.py setup.cfg setup.cfg.in setup.py test.py src/zope/__init__.py src/zope.tales.egg-info/PKG-INFO src/zope.tales.egg-info/SOURCES.txt src/zope.tales.egg-info/namespace_packages.txt src/zope.tales.egg-info/not-zip-safe src/zope.tales.egg-info/requires.txt src/zope.tales.egg-info/top_level.txt src/zope/tales/DEPENDENCIES.cfg src/zope/tales/__init__.py src/zope/tales/engine.py src/zope/tales/expressions.py src/zope/tales/interfaces.py src/zope/tales/pythonexpr.py src/zope/tales/tales.py src/zope/tales/tests/__init__.py src/zope/tales/tests/simpleexpr.py src/zope/tales/tests/test_expressions.py src/zope/tales/tests/test_tales.py workspace/__init__.py workspace/develop.py PK6>g4>Fzope/__init__.pyPKm4L<zope/__init__.pycPKҾ4zope/tales/__init__.pyPKҾ4@5OOzope/tales/tales.pyPKҾ4a0 Uzope/tales/pythonexpr.pyPKҾ4ǖ9''`zope/tales/expressions.pyPKҾ4Ɗt t zope/tales/interfaces.pyPKҾ4iYcczope/tales/engine.pyPKҾ4hAE%%?zope/tales/DEPENDENCIES.cfgPKm4(zope/tales/__init__.pycPKm4JAmmϝzope/tales/tales.pycPKm4̼n zope/tales/pythonexpr.pycPKm4/)4)4zope/tales/expressions.pycPKm4U$//Ozope/tales/interfaces.pycPKm4քdzope/tales/engine.pycPKm4KjEGG-INFO/requires.txtPKm4,x66jEGG-INFO/PKG-INFOPK1m4kEGG-INFO/not-zip-safePKm4-lEGG-INFO/top_level.txtPKm4flEGG-INFO/namespace_packages.txtPKm4\6lEGG-INFO/SOURCES.txtPKo