zope.security dependency on zope.exceptions

Fabio Tranchitella <[email protected]>
Newsgroups gmane.comp.web.zope.devel
Message-ID <[email protected]>
Happy New Year to everybody,

I'm working to isolate a core set of ZTK packages which are independent
from Zope and reusable outside the Zope community. One of them is
zope.security, which can be used (and it is useful, indeed) with non-zope
frameworks too.

While doing it, I'm trying to remove dependencies which are zope-specific,
to minimize the overhead for developers who are using the whole zope stack
(like me :)).

zope.security depends on zope.exceptions because it imports this symbol in
zope.security.checker:

    from zope.exceptions import DuplicationError

zope.exceptions defines DuplicationError as:

    class IDuplicationError(Interface):
        pass

    class DuplicationError(Exception):
        """A duplicate registration was attempted"""
        implements(IDuplicationError)

The zope.exceptions package contains "exception interfaces and
implementations which are so general purpose that they don't belong in Zope
application-specific packages.", as stated by the README.

I propose to make the remove the dependency between zope.security and
zope.exceptions with a conditional import:

 * if zope.exceptions is available, use DuplicationError from it;

 * if it is not available, define a zope.security-specific DuplicationError
   (which inherits from ValueError, maybe).

As using zope.exceptions only make sense if you are checking the exception
type importing its interface from the zope.exceptions package, and thus
depending on it, I see no risk in such a change.

Thoughts? Comments?

Fabio
_______________________________________________
Zope-Dev maillist  -  [email protected]
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.