[Zope-Checkins] CVS: Zope3/lib/python/Zope/Proxy - IContextWrapper.py:1.1.2.1

Jim Fulton jim@zope.com
Fri, 26 Apr 2002 14:27:44 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/Proxy
In directory cvs.zope.org:/tmp/cvs-serv29346

Added Files:
      Tag: SecurityProxy-branch
	IContextWrapper.py 
Log Message:
Changed security code to use security proxies and name-based
security. This has pretty far-reaching implications:

- You now protect names/operations, *not* values. This means it's as
  easy yo protect data attributes that have simple values as it is to
  protect methods.

- There is no longer a __permissions__ attribute. :)

- There is no longer a validate method in either security managers or
  policies.

- No more need to have a special compiler for restricted code.
  In exchange, lots of objects are proxies and code sometimes needs to
  be prepared to remove proxies.

In addition:

- Basic objects (None, strings, numbers, etc.) are not wrapped in
  context wrappers.

- There is a test that fails unless Python 2.3 is used.



=== Added File Zope3/lib/python/Zope/Proxy/IContextWrapper.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.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
# 
##############################################################################
"""

Revision information:
$Id: IContextWrapper.py,v 1.1.2.1 2002/04/26 18:27:44 jim Exp $
"""
from Interface import Interface

class IContextWrapper(Interface):

    def ContextWrapper(object, parent, **data):
        """Create a context wrapper for object in parent

        If the object is in a security proxy, then result will will be
        a security proxy for the unproxied object in context.

        Consider an object, o1, in a proxy p1 with a checker c1.

        If we call ContextWrapper(p1, parent, name='foo'), then we'll
        get::

          Proxy(Wrapper(o1, parent, name='foo'), c1)
          
        """

    def getWrapperData(ob):
        """Get the context wrapper data for an object
        """

    def getWrapperContainer(ob):
        """Get the object's container, as computed from a context wrapper
        """

    def getWrapperContext(ob):
        """Get the object's context, as computed from a context wrapper
        """

    def ContainmentIterator(ob):
        """Get an iterator for the object's containment chain
        """