[Zope-Checkins] CVS: Zope/lib/python/Zope/Startup -
warnfilter.py:1.1.8.1 warnfilter.xml:1.1.8.1
handlers.py:1.6.2.7 zopeschema.xml:1.7.2.9
Chris McDonough
chrism at zopemafia.com
Sun Dec 21 21:34:13 EST 2003
Update of /cvs-repository/Zope/lib/python/Zope/Startup
In directory cvs.zope.org:/tmp/cvs-serv15277/lib/python/Zope/Startup
Modified Files:
Tag: Zope-2_7-branch
handlers.py zopeschema.xml
Added Files:
Tag: Zope-2_7-branch
warnfilter.py warnfilter.xml
Log Message:
Backport the warnfilter and mime-types features from the HEAD into the 2.7 branch.
=== Added File Zope/lib/python/Zope/Startup/warnfilter.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.0 (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.
#
##############################################################################
"""Datatypes for warning filter component """
def warn_category(category):
import re, types
if not category:
return Warning
if re.match("^[a-zA-Z0-9_]+$", category):
try:
cat = eval(category)
except NameError:
raise ValueError("unknown warning category: %s" % `category`)
else:
i = category.rfind(".")
module = category[:i]
klass = category[i+1:]
try:
m = __import__(module, None, None, [klass])
except ImportError:
raise ValueError("invalid module name: %s" % `module`)
try:
cat = getattr(m, klass)
except AttributeError:
raise ValueError("unknown warning category: %s" % `category`)
if (not isinstance(cat, types.ClassType) or
not issubclass(cat, Warning)):
raise ValueError("invalid warning category: %s" % `category`)
return cat
def warn_action(val):
OK = ("error", "ignore", "always", "default", "module", "once")
if val not in OK:
raise ValueError, "warning action %s not one of %s" % (val, OK)
return val
def warning_filter_handler(section):
import warnings
# add the warning filter
warnings.filterwarnings(section.action, section.message, section.category,
section.module, section.lineno, 1)
return section
=== Added File Zope/lib/python/Zope/Startup/warnfilter.xml ===
<component prefix="Zope.Startup.warnfilter">
<sectiontype name="warnfilter" datatype=".warning_filter_handler">
<key name="action" datatype=".warn_action" default="default"/>
<key name="message" default=""/>
<key name="category" datatype=".warn_category" default="Warning"/>
<key name="module" default=""/>
<key name="lineno" datatype="integer" default="0"/>
</sectiontype>
</component>
=== Zope/lib/python/Zope/Startup/handlers.py 1.6.2.6 => 1.6.2.7 ===
--- Zope/lib/python/Zope/Startup/handlers.py:1.6.2.6 Sun Dec 21 18:05:01 2003
+++ Zope/lib/python/Zope/Startup/handlers.py Sun Dec 21 21:33:42 2003
@@ -153,6 +153,12 @@
L.append(d)
Products.__path__[:] = L
+ # Augment the set of MIME types:
+ if config.mime_types:
+ import OFS.content_types
+ OFS.content_types.add_files(config.mime_types)
+
+ # if no servers are defined, create default http server and ftp server
if not config.servers:
config.servers = []
=== Zope/lib/python/Zope/Startup/zopeschema.xml 1.7.2.8 => 1.7.2.9 ===
--- Zope/lib/python/Zope/Startup/zopeschema.xml:1.7.2.8 Thu Oct 2 15:08:45 2003
+++ Zope/lib/python/Zope/Startup/zopeschema.xml Sun Dec 21 21:33:42 2003
@@ -8,6 +8,7 @@
<import package="ZODB"/>
<import package="ZServer"/>
<import package="tempstorage"/>
+ <import package="Zope.Startup" file="warnfilter.xml"/>
<sectiontype name="logger" datatype=".LoggerFactory">
<description>
@@ -198,6 +199,42 @@
<!-- schema begins -->
+ <multisection type="warnfilter" attribute="warnfilters" name="*"
+ dataype="zLOG.warn_filter_handler">
+ <!-- from zLOG -->
+ <description>
+ A multisection which allows a user to set up a Python "warning" filter.
+ The following keys are valid within a warnfilter section:
+
+ action: one of the following strings:
+
+ "error" turn matching warnings into exceptions
+ "ignore" never print matching warnings
+ "always" always print matching warnings
+ "default" print the first occurrence of matching warnings
+ for each location where the warning is issued
+ "module" print the first occurrence of matching warnings
+ for each module where the warning is issued
+ "once" print only the first occurrence of matching
+ warnings, regardless of location
+
+ message: a string containing a regular expression that the
+ warning message must match (the match is compiled to
+ always be case-insensitive)
+
+ category: a Python dotted-path classname (must be a subclass of
+ Warning) of which the warning category must be a subclass in
+ order to match
+
+ module: a string containing a regular expression that the
+ module name must match (the match is compiled to be
+ case-sensitive)
+
+ lineno: an integer that the line number where the warning
+ occurred must match, or 0 to match all line numbers
+ </description>
+ </multisection>
+
<section type="environment" attribute="environment" name="*">
<description>
A section which allows a user to define arbitrary key-value pairs for
@@ -229,6 +266,22 @@
</description>
<metadefault>$instancehome/var</metadefault>
</key>
+
+ <multikey name="mime-types" datatype="existing-file">
+ <description>
+ This specifies additional lists of MIME types that should be
+ loaded into Python's "mimetypes" module. The files should have
+ the same form as the mime.types file distributed with the Apache
+ HTTP server.
+
+ Each line describing a MIME type should contain the major/minor
+ type, followed by a space-separated list of file extensions used
+ for files of that type. The extensions must not include the '.'
+ used to separate an extension from the base file name.
+
+ Blank lines and lines beginning with a '#' are ignored.
+ </description>
+ </multikey>
<multikey name="products" datatype="existing-directory">
<description>
More information about the Zope-Checkins
mailing list