PK Ih4~7 zope/__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__)
PK 4U%$ zope/__init__.pyc;
zSDc @ sO y e d i e Wn1 e j
o% Z d k l Z e e e Z n Xd S( s
pkg_resources( s extend_pathN( s
__import__s declare_namespaces __name__s ImportErrors es pkgutils extend_paths __path__( s es extend_paths __path__( ( s+ build/bdist.linux-i686/egg/zope/__init__.pys ? s
PK 4+T ! zope/exceptions/_notfounderror.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.
#
##############################################################################
"""Not Found Error
$Id: _notfounderror.py 27082 2004-08-12 20:03:58Z srichter $
"""
from zope.interface.common.interfaces import IKeyError
from zope.interface import implements
class INotFoundError(IKeyError):
pass
class NotFoundError(KeyError):
"""A resource could not be found.
"""
implements(INotFoundError)
PK 4w zope/exceptions/_duplicate.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.
#
##############################################################################
"""Duplication Error
$Id: _duplicate.py 27082 2004-08-12 20:03:58Z srichter $
"""
from zope.interface import implements, Interface
class IDuplicationError(Interface):
pass
class DuplicationError(Exception):
"""A duplicate registration was attempted"""
implements(IDuplicationError)
PK 4y! zope/exceptions/__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.
#
##############################################################################
"""General exceptions that wish they were standard exceptions
These exceptions are so general purpose that they don't belong in Zope
application-specific packages.
$Id: __init__.py 66453 2006-04-04 21:51:37Z tseaver $
"""
from zope.exceptions._notfounderror import NotFoundError, INotFoundError
from zope.exceptions._duplicate import DuplicationError, IDuplicationError
# Importing these interfaces from here is deprecated!
# avoid hard depency on zope.security:
try:
from zope.security.interfaces import IUnauthorized
from zope.security.interfaces import Unauthorized
from zope.security.interfaces import IForbidden
from zope.security.interfaces import Forbidden
from zope.security.interfaces import IForbiddenAttribute
from zope.security.interfaces import ForbiddenAttribute
except ImportError:
pass
PK 4vb
zope/exceptions/interfaces.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.
#
##############################################################################
"""ITracebackSupplement interface definition.
$Id: interfaces.py 25177 2004-06-02 13:17:31Z jim $
"""
from zope.interface import Interface, Attribute
class ITracebackSupplement(Interface):
"""Provides valuable information to supplement an exception traceback.
The interface is geared toward providing meaningful feedback when
exceptions occur in user code written in mini-languages like
Zope page templates and restricted Python scripts.
"""
source_url = Attribute(
'source_url',
"""Optional. Set to URL of the script where the exception occurred.
Normally this generates a URL in the traceback that the user
can visit to manage the object. Set to None if unknown or
not available.
"""
)
line = Attribute(
'line',
"""Optional. Set to the line number (>=1) where the exception
occurred.
Set to 0 or None if the line number is unknown.
"""
)
column = Attribute(
'column',
"""Optional. Set to the column offset (>=0) where the exception
occurred.
Set to None if the column number is unknown.
"""
)
expression = Attribute(
'expression',
"""Optional. Set to the expression that was being evaluated.
Set to None if not available or not applicable.
"""
)
warnings = Attribute(
'warnings',
"""Optional. Set to a sequence of warning messages.
Set to None if not available, not applicable, or if the exception
itself provides enough information.
"""
)
def getInfo(as_html=0):
"""Optional. Returns a string containing any other useful info.
If as_html is set, the implementation must HTML-quote the result
(normally using cgi.escape()). Returns None to provide no
extra info.
"""
PK 4ʨ % zope/exceptions/exceptionformatter.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.
#
##############################################################################
"""An exception formatter that shows traceback supplements and traceback info,
optionally in HTML.
$Id: exceptionformatter.py 27194 2004-08-20 19:26:59Z jim $
"""
import sys
import cgi
import linecache
DEBUG_EXCEPTION_FORMATTER = 1
class TextExceptionFormatter(object):
line_sep = '\n'
show_revisions = 0
def __init__(self, limit=None):
self.limit = limit
def escape(self, s):
return s
def getPrefix(self):
return 'Traceback (innermost last):'
def getLimit(self):
limit = self.limit
if limit is None:
limit = getattr(sys, 'tracebacklimit', None)
return limit
def getRevision(self, globals):
if not self.show_revisions:
return None
revision = globals.get('__revision__', None)
if revision is None:
# Incorrect but commonly used spelling
revision = globals.get('__version__', None)
if revision is not None:
try:
revision = str(revision).strip()
except (ValueError, AttributeError):
# Just in case revisions cannot be converted to strings.
revision = '???'
return revision
def formatSupplementLine(self, line):
return ' - %s' % line
def formatSourceURL(self, url):
return [self.formatSupplementLine(url)]
def formatSupplement(self, supplement, tb):
result = []
fmtLine = self.formatSupplementLine
url = getattr(supplement, 'source_url', None)
if url is not None:
result.extend(self.formatSourceURL(url))
line = getattr(supplement, 'line', 0)
if line == -1:
line = tb.tb_lineno
col = getattr(supplement, 'column', -1)
if line:
if col is not None and col >= 0:
result.append(fmtLine('Line %s, Column %s' % (
line, col)))
else:
result.append(fmtLine('Line %s' % line))
elif col is not None and col >= 0:
result.append(fmtLine('Column %s' % col))
expr = getattr(supplement, 'expression', None)
if expr:
result.append(fmtLine('Expression: %s' % expr))
warnings = getattr(supplement, 'warnings', None)
if warnings:
for warning in warnings:
result.append(fmtLine('Warning: %s' % warning))
getInfo = getattr(supplement, 'getInfo', None)
if getInfo is not None:
try:
extra = getInfo()
if extra:
extra = self.escape(extra)
if self.line_sep != "\n":
extra = extra.replace(" ", " ")
extra = extra.replace("\n", self.line_sep)
result.append(extra)
except:
if DEBUG_EXCEPTION_FORMATTER:
import traceback
traceback.print_exc()
# else just swallow the exception.
return result
def formatTracebackInfo(self, tbi):
return self.formatSupplementLine('__traceback_info__: %s' % (tbi, ))
def formatLine(self, tb):
f = tb.tb_frame
lineno = tb.tb_lineno
co = f.f_code
filename = co.co_filename
name = co.co_name
locals = f.f_locals
globals = f.f_globals
modname = globals.get('__name__', filename)
s = ' Module %s, line %d' % (modname, lineno)
revision = self.getRevision(globals)
if revision:
s = s + ', rev. %s' % revision
s = s + ', in %s' % name
result = []
result.append(self.escape(s))
# Append the source line, if available
line = linecache.getline(filename, lineno)
if line:
result.append(" " + self.escape(line.strip()))
# Output a traceback supplement, if any.
if '__traceback_supplement__' in locals:
# Use the supplement defined in the function.
tbs = locals['__traceback_supplement__']
elif '__traceback_supplement__' in globals:
# Use the supplement defined in the module.
# This is used by Scripts (Python).
tbs = globals['__traceback_supplement__']
else:
tbs = None
if tbs is not None:
factory = tbs[0]
args = tbs[1:]
try:
supp = factory(*args)
result.extend(self.formatSupplement(supp, tb))
except:
if DEBUG_EXCEPTION_FORMATTER:
import traceback
traceback.print_exc()
# else just swallow the exception.
try:
tbi = locals.get('__traceback_info__', None)
if tbi is not None:
result.append(self.formatTracebackInfo(tbi))
except:
if DEBUG_EXCEPTION_FORMATTER:
import traceback
traceback.print_exc()
# else just swallow the exception.
return self.line_sep.join(result)
def formatExceptionOnly(self, etype, value):
import traceback
return self.line_sep.join(
traceback.format_exception_only(etype, value))
def formatLastLine(self, exc_line):
return self.escape(exc_line)
def formatException(self, etype, value, tb):
# The next line provides a way to detect recursion.
__exception_formatter__ = 1
result = [self.getPrefix() + '\n']
limit = self.getLimit()
n = 0
while tb is not None and (limit is None or n < limit):
if tb.tb_frame.f_locals.get('__exception_formatter__'):
# Stop recursion.
result.append('(Recursive formatException() stopped)\n')
break
line = self.formatLine(tb)
result.append(line + '\n')
tb = tb.tb_next
n = n + 1
exc_line = self.formatExceptionOnly(etype, value)
result.append(self.formatLastLine(exc_line))
return result
class HTMLExceptionFormatter(TextExceptionFormatter):
line_sep = '
\r\n'
def escape(self, s):
return cgi.escape(s)
def getPrefix(self):
return '
Traceback (innermost last):\r\n