Hash: SHA1

Yvo Schubbe wrote:
> Log message for revision 39508:
>   - reverted Portal.py change of r39125 to fix BBB temporarily
>   Note: PortalGenerator will soon be removed completely from the trunk.

Sounds fine.  I'd like to add a DeprecationWarning in manage_addCMFSite,
which is the entry point which drives PortalGenerator.  I plan to write
it as::

 def manage_addCMFSite(self, id, title='Portal', description='',
                       email_from_address='[EMAIL PROTECTED]',
                       email_from_name='Portal Administrator',
                       validate_email=0, default_charset='',
     """ Adds a portal instance.
     from warnings import warn

     warn("manage_addCMFSite is a deprecated way to create a CMF site; "
          "in the "
          "future, please use CMFSetup's 'Configured CMF Site' (from "
          "the ZMI "
          "add menu) or 'CMFSetup.factory.addConfiguredSite' (from "
          "Python).  "
         "manage_addCMFSite will be removed in CMF 2.0.",
         DeprecationWarning, 2)

Note that I have just figured out that we can make DeprecationWarnings
more useful by passing the 'stacklevel' argument to 'warnings.warn';
passing a value of 2 for that argument causes the warning to be reported
against the *caller* of the code issuing the warning, which makes it
possible to find and remove the deprecated use.

On another note:  we should probably avoid all attempts to muck with the
'warnings.filters' data structure in tests.  Getting that wrong causes
non-local breakage.

  - Test cases which just want to suppress warnings, should use
    'Products.CMFCore.tests.base.testcase.WarningInterceptor' as a base
    class, and call its '_trap_warning_output' / '_free_warning_output'
    methods as appropriate ('_free_warning_output' should be in

  - Test cases which actually want to check that warnings are emitted
    should examine either their own '__warningregistry__' (for
    stacklevel=2 warnings) or the '__warningregistry__' of the
    module-under-test, rather than trying to test the output stream.

- --
Tres Seaver          +1 202-558-7113          [EMAIL PROTECTED]
Palladion Software   "Excellence by Design"    http://palladion.com
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

Zope-CMF maillist  -  Zope-CMF@lists.zope.org

See http://collector.zope.org/CMF for bug reports and feature requests

Reply via email to