[Checkins] SVN: Products.GenericSetup/trunk/Products/GenericSetup/
- removed deprecated code
Yvo Schubbe
y.2008 at wcm-solutions.de
Fri Jul 18 06:02:47 EDT 2008
Log message for revision 88483:
- removed deprecated code
- some related whitespace and import cleanup
Changed:
U Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt
U Products.GenericSetup/trunk/Products/GenericSetup/interfaces.py
U Products.GenericSetup/trunk/Products/GenericSetup/registry.py
U Products.GenericSetup/trunk/Products/GenericSetup/testing.py
U Products.GenericSetup/trunk/Products/GenericSetup/tests/test_tool.py
U Products.GenericSetup/trunk/Products/GenericSetup/tool.py
U Products.GenericSetup/trunk/Products/GenericSetup/utils.py
-=-
Modified: Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt 2008-07-18 09:56:00 UTC (rev 88482)
+++ Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt 2008-07-18 10:02:47 UTC (rev 88483)
@@ -4,6 +4,8 @@
GenericSetup 1.5.0 (unreleased)
-------------------------------
+- tool and utils: Removed deprecated code.
+
- Update PropertyManagerHelpers to make it possible to remove elements from a
property by adding a remove="True" attribute to the element. This can
also be used to reorder elements since new elements are always added
Modified: Products.GenericSetup/trunk/Products/GenericSetup/interfaces.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/interfaces.py 2008-07-18 09:56:00 UTC (rev 88482)
+++ Products.GenericSetup/trunk/Products/GenericSetup/interfaces.py 2008-07-18 10:02:47 UTC (rev 88483)
@@ -451,26 +451,10 @@
o Return None if the data should not be encoded.
"""
- def getImportContextID():
-
- """ Get the ID of the active import context.
-
- DEPRECATED. The idea of a stateful active import context is
- going away.
- """
-
def getBaselineContextID():
""" Get the ID of the base profile for this configuration.
"""
- def setImportContext( context_id ):
-
- """ Set the ID of the active import context and update the registries.
-
- DEPRECATED. The idea of a stateful active import context is
- going away.
- """
-
def setBaselineContext( context_id, encoding=None):
""" Specify the base profile for this configuration.
"""
@@ -529,30 +513,6 @@
step
"""
- def runImportStep(step_id, run_dependencies=True, purge_old=None):
-
- """ Execute a given setup step from the current
- _import_context_id context.
-
- o 'step_id' is the ID of the step to run.
-
- o If 'purge_old' is True, then run the step after purging any
- "old" setup first (this is the responsibility of the step,
- which must check the context we supply).
-
- o If 'run_dependencies' is True, then run any out-of-date
- dependency steps first.
-
- o Return a mapping, with keys:
-
- 'steps' -- a sequence of IDs of the steps run.
-
- 'messages' -- a dictionary holding messages returned from each
- step
-
- DEPRECATED. Use runImportStepFromProfile instead.
- """
-
def runAllImportStepsFromProfile(profile_id, purge_old=None, ignore_dependencies=False):
""" Run all setup steps for the given profile in dependency order.
@@ -575,25 +535,6 @@
step
"""
- def runAllImportSteps(purge_old=None):
-
- """ Run all setup steps for the _import_context_id profile in
- dependency order.
-
- o If 'purge_old' is True, then run each step after purging any
- "old" setup first (this is the responsibility of the step,
- which must check the context we supply).
-
- o Return a mapping, with keys:
-
- 'steps' -- a sequence of IDs of the steps run.
-
- 'messages' -- a dictionary holding messages returned from each
- step
-
- DEPRECATED. Use runAllImportStepsFromProfile instead.
- """
-
def runExportStep( step_id ):
""" Generate a tarball containing artifacts from one export step.
Modified: Products.GenericSetup/trunk/Products/GenericSetup/registry.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/registry.py 2008-07-18 09:56:00 UTC (rev 88482)
+++ Products.GenericSetup/trunk/Products/GenericSetup/registry.py 2008-07-18 10:02:47 UTC (rev 88483)
@@ -24,7 +24,6 @@
import App.Product
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from zope.interface import implements
-from warnings import warn
from interfaces import BASE
from interfaces import IImportStepRegistry
Modified: Products.GenericSetup/trunk/Products/GenericSetup/testing.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/testing.py 2008-07-18 09:56:00 UTC (rev 88482)
+++ Products.GenericSetup/trunk/Products/GenericSetup/testing.py 2008-07-18 10:02:47 UTC (rev 88483)
@@ -165,7 +165,7 @@
try:
from Testing.ZopeTestCase.layer import ZopeLite
except ImportError:
- pass # Zope < 2.11
+ pass # BBB: Zope < 2.11
else:
ExportImportZCMLLayer.__bases__ = (ZopeLite,)
Modified: Products.GenericSetup/trunk/Products/GenericSetup/tests/test_tool.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/tests/test_tool.py 2008-07-18 09:56:00 UTC (rev 88482)
+++ Products.GenericSetup/trunk/Products/GenericSetup/tests/test_tool.py 2008-07-18 10:02:47 UTC (rev 88483)
@@ -206,7 +206,7 @@
self.assertEqual( export_registry.getStep( 'one' ), ONE_FUNC )
- def test_runImportStep_nonesuch( self ):
+ def test_runImportStepFromProfile_nonesuch(self):
site = self._makeSite()
@@ -215,7 +215,7 @@
self.assertRaises( KeyError, tool.runImportStepFromProfile,
'', 'nonesuch' )
- def test_runImportStep_simple( self ):
+ def test_runImportStepFromProfile_simple(self):
TITLE = 'original title'
site = self._makeSite( TITLE )
@@ -247,7 +247,7 @@
self.assertEqual(_after_import_events[0].steps, ['simple'])
self.assertEqual(_after_import_events[0].full_import, False)
- def test_runImportStep_dependencies( self ):
+ def test_runImportStepFromProfile_dependencies(self):
TITLE = 'original title'
site = self._makeSite( TITLE )
@@ -284,9 +284,8 @@
self.assertEqual(_after_import_events[0].steps, ['dependable', 'dependent'])
self.assertEqual(_after_import_events[0].full_import, False)
+ def test_runImportStepFromProfile_skip_dependencies(self):
- def test_runImportStep_skip_dependencies( self ):
-
TITLE = 'original title'
site = self._makeSite( TITLE )
@@ -320,7 +319,7 @@
self.assertEqual(_after_import_events[0].steps, ['dependent'])
self.assertEqual(_after_import_events[0].full_import, False)
- def test_runImportStep_default_purge( self ):
+ def test_runImportStepFromProfile_default_purge(self):
site = self._makeSite()
@@ -335,7 +334,7 @@
self.assertEqual( result[ 'messages' ][ 'purging' ], 'Purged' )
self.failUnless( site.purged )
- def test_runImportStep_explicit_purge( self ):
+ def test_runImportStepFromProfile_explicit_purge(self):
site = self._makeSite()
@@ -351,7 +350,7 @@
self.assertEqual( result[ 'messages' ][ 'purging' ], 'Purged' )
self.failUnless( site.purged )
- def test_runImportStep_skip_purge( self ):
+ def test_runImportStepFromProfile_skip_purge(self):
site = self._makeSite()
@@ -367,7 +366,7 @@
self.assertEqual( result[ 'messages' ][ 'purging' ], 'Unpurged' )
self.failIf( site.purged )
- def test_runImportStep_consistent_context( self ):
+ def test_runImportStepFromProfile_consistent_context(self):
site = self._makeSite()
@@ -382,7 +381,7 @@
purge_old=False )
self.failIf( site.purged )
- def test_runAllImportSteps_empty( self ):
+ def test_runAllImportStepsFromProfile_empty(self):
site = self._makeSite()
tool = self._makeOne('setup_tool').__of__( site )
@@ -391,7 +390,7 @@
self.assertEqual( len(result['steps']), 3 )
- def test_runAllImportSteps_sorted_default_purge( self ):
+ def test_runAllImportStepsFromProfile_sorted_default_purge(self):
TITLE = 'original title'
PROFILE_ID = 'snapshot-testing'
@@ -429,7 +428,7 @@
logged = [x for x in tool.objectIds('File') if x.startswith(prefix)]
self.assertEqual(len(logged), 1)
- def test_runAllImportSteps_unicode_profile_id_creates_reports( self ):
+ def test_runAllImportStepsFromProfile_unicode_profile_id_creates_reports(self):
TITLE = 'original title'
PROFILE_ID = u'snapshot-testing'
@@ -450,7 +449,7 @@
logged = [x for x in tool.objectIds('File') if x.startswith(prefix)]
self.assertEqual(len(logged), 1)
- def test_runAllImportSteps_sorted_explicit_purge( self ):
+ def test_runAllImportStepsFromProfile_sorted_explicit_purge(self):
site = self._makeSite()
tool = self._makeOne('setup_tool').__of__( site )
@@ -475,7 +474,7 @@
self.assertEqual( result['steps'][5], 'dependent' )
self.failUnless( site.purged )
- def test_runAllImportSteps_sorted_skip_purge( self ):
+ def test_runAllImportStepsFromProfile_sorted_skip_purge(self):
site = self._makeSite()
tool = self._makeOne('setup_tool').__of__( site )
@@ -500,7 +499,7 @@
self.assertEqual( result['steps'][5], 'dependent' )
self.failIf( site.purged )
- def test_runAllImportStepsFromProfileWithoutDepends( self ):
+ def test_runAllImportStepsFromProfile_without_depends(self):
from Products.GenericSetup.metadata import METADATA_XML
self._makeFile(METADATA_XML, _METADATA_XML)
@@ -518,7 +517,7 @@
result = tool.runAllImportStepsFromProfile('profile-other:foo', ignore_dependencies=True)
self.assertEqual(_imported, [self._PROFILE_PATH])
- def test_runAllImportStepsFromProfileWithDepends( self ):
+ def test_runAllImportStepsFromProfile_with_depends(self):
from Products.GenericSetup.metadata import METADATA_XML
self._makeFile(METADATA_XML, _METADATA_XML)
@@ -539,7 +538,7 @@
self.assertEqual(_imported, [self._PROFILE_PATH2, self._PROFILE_PATH])
- def test_runAllImportStepsFromProfileStepRegistrationWithDepends( self ):
+ def test_runAllImportStepsFromProfile_step_registration_with_depends(self):
from Products.GenericSetup.metadata import METADATA_XML
self._makeFile(METADATA_XML, _METADATA_XML)
@@ -568,8 +567,6 @@
# ensure the additional step on foo was imported
self.failUnless('one' in result['steps'])
-
-
def test_runExportStep_nonesuch( self ):
site = self._makeSite()
Modified: Products.GenericSetup/trunk/Products/GenericSetup/tool.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/tool.py 2008-07-18 09:56:00 UTC (rev 88482)
+++ Products.GenericSetup/trunk/Products/GenericSetup/tool.py 2008-07-18 10:02:47 UTC (rev 88483)
@@ -15,10 +15,9 @@
$Id$
"""
+import logging
import os
import time
-import logging
-from warnings import warn
from cgi import escape
from AccessControl import ClassSecurityInfo
@@ -28,38 +27,35 @@
from OFS.Image import File
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from ZODB.POSException import ConflictError
-from zope.interface import implements
from zope import event
+from zope.interface import implements
-from interfaces import BASE
-from interfaces import EXTENSION
-from interfaces import ISetupTool
-from interfaces import SKIPPED_FILES
-from permissions import ManagePortal
-from events import BeforeProfileImportEvent
-from events import ProfileImportedEvent
from context import DirectoryImportContext
+from context import SnapshotExportContext
from context import SnapshotImportContext
from context import TarballExportContext
from context import TarballImportContext
-from context import SnapshotExportContext
from differ import ConfigDiff
-from registry import ImportStepRegistry
+from events import BeforeProfileImportEvent
+from events import ProfileImportedEvent
+from interfaces import BASE
+from interfaces import EXTENSION
+from interfaces import ISetupTool
+from interfaces import SKIPPED_FILES
+from permissions import ManagePortal
from registry import ExportStepRegistry
+from registry import ImportStepRegistry
from registry import ToolsetRegistry
-from registry import _profile_registry
-from registry import _import_step_registry
from registry import _export_step_registry
-
-from upgrade import listUpgradeSteps
-from upgrade import listProfilesWithUpgrades
+from registry import _import_step_registry
+from registry import _profile_registry
from upgrade import _upgrade_registry
-
-from utils import _getDottedName
-from utils import _resolveDottedName
-from utils import _wwwdir
+from upgrade import listProfilesWithUpgrades
+from upgrade import listUpgradeSteps
from utils import _computeTopologicalSort
from utils import _getProductPath
+from utils import _resolveDottedName
+from utils import _wwwdir
IMPORT_STEPS_XML = 'import_steps.xml'
EXPORT_STEPS_XML = 'export_steps.xml'
@@ -168,8 +164,6 @@
meta_type = 'Generic Setup Tool'
_baseline_context_id = ''
- # BBB _import_context_id is a vestige of a stateful import context
- _import_context_id = ''
_profile_upgrade_versions = {}
@@ -186,47 +180,16 @@
#
security.declareProtected(ManagePortal, 'getEncoding')
def getEncoding(self):
-
""" See ISetupTool.
"""
return 'utf-8'
- security.declareProtected(ManagePortal, 'getImportContextID')
- def getImportContextID(self):
-
- """ See ISetupTool.
- """
- warn('getImportContextId, and the very concept of a stateful '
- 'active import context, is deprecated. You can find the '
- 'base profile that was applied using getBaselineContextID.',
- DeprecationWarning, stacklevel=2)
- return self._import_context_id
-
security.declareProtected(ManagePortal, 'getBaselineContextID')
def getBaselineContextID(self):
-
""" See ISetupTool.
"""
return self._baseline_context_id
- security.declareProtected(ManagePortal, 'setImportContext')
- def setImportContext(self, context_id, encoding=None):
- """ See ISetupTool.
- """
- warn('setImportContext is deprecated. Use setBaselineContext to '
- 'specify the baseline context, and/or runImportStepFromProfile '
- 'to run the steps from a specific import context.',
- DeprecationWarning, stacklevel=2)
- self._import_context_id = context_id
-
- context_type = BASE # snapshots are always baseline contexts
- if context_id.startswith('profile-'):
- profile_info = _profile_registry.getProfileInfo(context_id[8:])
- context_type = profile_info['type']
-
- if context_type == BASE:
- self.setBaselineContext(context_id, encoding)
-
security.declareProtected(ManagePortal, 'setBaselineContext')
def setBaselineContext(self, context_id, encoding=None):
""" See ISetupTool.
@@ -234,13 +197,11 @@
self._baseline_context_id = context_id
self.applyContextById(context_id, encoding)
-
security.declareProtected(ManagePortal, 'applyContextById')
def applyContextById(self, context_id, encoding=None):
context = self._getImportContext(context_id)
self.applyContext(context, encoding)
-
security.declareProtected(ManagePortal, 'applyContext')
def applyContext(self, context, encoding=None):
self._updateImportStepsRegistry(context, encoding)
@@ -248,14 +209,12 @@
security.declareProtected(ManagePortal, 'getImportStepRegistry')
def getImportStepRegistry(self):
-
""" See ISetupTool.
"""
return self._import_registry
security.declareProtected(ManagePortal, 'getExportStepRegistry')
def getExportStepRegistry(self):
-
""" See ISetupTool.
"""
return self._export_registry
@@ -308,7 +267,6 @@
security.declareProtected(ManagePortal, 'getToolsetRegistry')
def getToolsetRegistry(self):
-
""" See ISetupTool.
"""
return self._toolset_registry
@@ -318,7 +276,6 @@
run_dependencies=True, purge_old=None):
""" See ISetupTool.
"""
- old_context = self._import_context_id
context = self._getImportContext(profile_id, purge_old)
self.applyContext(context)
@@ -326,7 +283,6 @@
info = self.getImportStepMetadata(step_id)
if info is None:
- self._import_context_id = old_context
raise ValueError, 'No such import step: %s' % step_id
dependencies = info.get('dependencies', ())
@@ -351,39 +307,20 @@
message_list.extend( ['%s: %s' % x[1:] for x in context.listNotes()] )
messages[step_id] = '\n'.join(message_list)
- self._import_context_id = old_context
-
event.notify(ProfileImportedEvent(self, profile_id, steps, full_import))
return { 'steps' : steps, 'messages' : messages }
- security.declareProtected(ManagePortal, 'runImportStep')
- def runImportStep(self, step_id, run_dependencies=True, purge_old=None):
-
- """ See ISetupTool.
- """
- warn('The runImportStep method is deprecated. Please use '
- 'runImportStepFromProfile instead.',
- DeprecationWarning, stacklevel=2)
- return self.runImportStepFromProfile(self._import_context_id,
- step_id,
- run_dependencies,
- purge_old,
- )
-
security.declareProtected(ManagePortal, 'runAllImportStepsFromProfile')
def runAllImportStepsFromProfile(self,
profile_id,
purge_old=None,
ignore_dependencies=False,
archive=None):
-
""" See ISetupTool.
"""
__traceback_info__ = profile_id
- old_context = self._import_context_id
-
result = self._runImportStepsFromContext(purge_old=purge_old,
profile_id=profile_id,
archive=archive,
@@ -395,39 +332,22 @@
name = self._mangleTimestampName(prefix, 'log')
self._createReport(name, result['steps'], result['messages'])
- self._import_context_id = old_context
-
return result
- security.declareProtected(ManagePortal, 'runAllImportSteps')
- def runAllImportSteps(self, purge_old=None):
-
- """ See ISetupTool.
- """
- warn('The runAllImportSteps method is deprecated. Please use '
- 'runAllImportStepsFromProfile instead.',
- DeprecationWarning, stacklevel=2)
- context_id = self._import_context_id
- return self.runAllImportStepsFromProfile(self._import_context_id,
- purge_old)
-
security.declareProtected(ManagePortal, 'runExportStep')
def runExportStep(self, step_id):
-
""" See ISetupTool.
"""
return self._doRunExportSteps([step_id])
security.declareProtected(ManagePortal, 'runAllExportSteps')
def runAllExportSteps(self):
-
""" See ISetupTool.
"""
return self._doRunExportSteps(self.listExportSteps())
security.declareProtected(ManagePortal, 'createSnapshot')
def createSnapshot(self, snapshot_id):
-
""" See ISetupTool.
"""
context = SnapshotExportContext(self, snapshot_id)
@@ -473,7 +393,6 @@
security.declareProtected(ManagePortal, 'markupComparison')
def markupComparison(self, lines):
-
""" See ISetupTool.
"""
result = []
@@ -592,7 +511,6 @@
security.declareProtected(ManagePortal, 'manage_importSelectedSteps')
def manage_importAllSteps(self, context_id=None):
-
""" Import all steps.
"""
if context_id is None:
@@ -606,7 +524,6 @@
security.declareProtected(ManagePortal, 'manage_importExtensions')
def manage_importExtensions(self, RESPONSE, profile_ids=()):
-
""" Import all steps for the selected extension profiles.
"""
detail = {}
@@ -646,7 +563,6 @@
security.declareProtected(ManagePortal, 'manage_exportSelectedSteps')
def manage_exportSelectedSteps(self, ids, RESPONSE):
-
""" Export the steps selected by the user.
"""
if not ids:
@@ -661,7 +577,6 @@
security.declareProtected(ManagePortal, 'manage_exportAllSteps')
def manage_exportAllSteps(self, RESPONSE):
-
""" Export all steps.
"""
result = self.runAllExportSteps()
@@ -681,7 +596,6 @@
security.declareProtected(ManagePortal, 'listSnapshotInfo')
def listSnapshotInfo(self):
-
""" Return a list of mappings describing available snapshots.
o Keys include:
@@ -707,7 +621,6 @@
security.declareProtected(ManagePortal, 'listProfileInfo')
def listProfileInfo(self):
-
""" Return a list of mappings describing registered profiles.
Base profile is listed first, extensions are sorted.
@@ -735,7 +648,6 @@
security.declareProtected(ManagePortal, 'listContextInfos')
def listContextInfos(self):
-
""" List registered profiles and snapshots.
"""
def readableType(x):
@@ -780,7 +692,6 @@
security.declareProtected(ManagePortal, 'manage_createSnapshot')
def manage_createSnapshot(self, RESPONSE, snapshot_id=None):
-
""" Create a snapshot with the given ID.
o If no ID is passed, generate one.
@@ -914,7 +825,6 @@
except KeyError:
return ()
-
security.declareProtected(ManagePortal, 'listProfilesWithUpgrades')
def listProfilesWithUpgrades(self):
return listProfilesWithUpgrades()
@@ -980,7 +890,6 @@
#
security.declarePrivate('_getImportContext')
def _getImportContext(self, context_id, should_purge=None, archive=None):
-
""" Crack ID and generate appropriate import context.
"""
encoding = self.getEncoding()
@@ -1016,11 +925,8 @@
security.declarePrivate('_updateImportStepsRegistry')
def _updateImportStepsRegistry(self, context, encoding):
-
""" Update our import steps registry from our profile.
"""
- if context is None:
- context = self._getImportContext(self._import_context_id)
xml = context.readDataFile(IMPORT_STEPS_XML)
if xml is None:
return
@@ -1046,11 +952,8 @@
security.declarePrivate('_updateExportStepsRegistry')
def _updateExportStepsRegistry(self, context, encoding):
-
""" Update our export steps registry from our profile.
"""
- if context is None:
- context = self._getImportContext(self._import_context_id)
xml = context.readDataFile(EXPORT_STEPS_XML)
if xml is None:
return
@@ -1072,7 +975,6 @@
security.declarePrivate('_doRunImportStep')
def _doRunImportStep(self, step_id, context):
-
""" Run a single import step, using a pre-built context.
"""
__traceback_info__ = step_id
@@ -1093,7 +995,6 @@
security.declarePrivate('_doRunExportSteps')
def _doRunExportSteps(self, steps):
-
""" See ISetupTool.
"""
context = TarballExportContext(self)
@@ -1121,7 +1022,6 @@
, 'filename' : context.getArchiveFilename()
}
-
security.declareProtected(ManagePortal, 'getProfileDependencyChain')
def getProfileDependencyChain(self, profile_id, seen=None):
if seen is None:
@@ -1139,7 +1039,6 @@
return chain
-
security.declarePrivate('_runImportStepsFromContext')
def _runImportStepsFromContext(self,
steps=None,
@@ -1206,7 +1105,6 @@
security.declarePrivate('_mangleTimestampName')
def _mangleTimestampName(self, prefix, ext=None):
-
""" Create a mangled ID using a timestamp.
"""
timestamp = time.gmtime()
@@ -1222,7 +1120,6 @@
security.declarePrivate('_createReport')
def _createReport(self, name, steps, messages):
-
""" Record the results of a run.
"""
lines = []
@@ -1252,6 +1149,7 @@
InitializeClass(SetupTool)
+
_PLAINTEXT_DIFF_HEADER ="""\
Comparing configurations: '%s' and '%s'
Modified: Products.GenericSetup/trunk/Products/GenericSetup/utils.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/utils.py 2008-07-18 09:56:00 UTC (rev 88482)
+++ Products.GenericSetup/trunk/Products/GenericSetup/utils.py 2008-07-18 10:02:47 UTC (rev 88483)
@@ -24,7 +24,6 @@
from xml.dom.minidom import Element
from xml.dom.minidom import Node
from xml.dom.minidom import parseString
-from xml.sax.handler import ContentHandler
from xml.parsers.expat import ExpatError
import Products
@@ -35,7 +34,6 @@
from OFS.interfaces import IOrderedContainer
from Products.Five.utilities.interfaces import IMarkerInterfaces
from zope.component import queryMultiAdapter
-from zope.deprecation import deprecated
from zope.interface import directlyProvides
from zope.interface import implements
from zope.interface import implementsOnly
@@ -153,42 +151,6 @@
return title, description
-deprecated('HandlerBase',
- 'SAX based XML parsing is no longer supported by GenericSetup. '
- 'HandlerBase will be removed in GenericSetup 1.5.')
-
-class HandlerBase( ContentHandler ):
-
- _encoding = None
- _MARKER = object()
-
- def _extract( self, attrs, key, default=None ):
-
- result = attrs.get( key, self._MARKER )
-
- if result is self._MARKER:
- return default
-
- return self._encode( result )
-
- def _extractBoolean( self, attrs, key, default ):
-
- result = attrs.get( key, self._MARKER )
-
- if result is self._MARKER:
- return default
-
- result = result.lower()
- return result in ( '1', 'yes', 'true' )
-
- def _encode( self, content ):
-
- if self._encoding is None:
- return content
-
- return content.encode( self._encoding )
-
-
##############################################################################
# WARNING: PLEASE DON'T USE THE CONFIGURATOR PATTERN. THE RELATED BASE CLASSES
# WILL BECOME DEPRECATED AS SOON AS GENERICSETUP ITSELF NO LONGER USES THEM.
More information about the Checkins
mailing list