[Zope3-checkins] CVS: Zope3/src/zope/security/examples -
sandbox.py:1.5 sandbox_security.py:1.8
Stephan Richter
srichter at cosmos.phy.tufts.edu
Mon Feb 16 17:04:19 EST 2004
Update of /cvs-repository/Zope3/src/zope/security/examples
In directory cvs.zope.org:/tmp/cvs-serv9480/src/zope/security/examples
Modified Files:
sandbox.py sandbox_security.py
Log Message:
Fixed the example, which is, in my opinion, pretty cool.
I originally planned to use this code for the spacesuits recipe, but
unfortunately it is too complex, so I will have to write my own code. But
I will definitely use the ideas used here.
=== Zope3/src/zope/security/examples/sandbox.py 1.4 => 1.5 ===
--- Zope3/src/zope/security/examples/sandbox.py:1.4 Wed Jun 4 05:09:47 2003
+++ Zope3/src/zope/security/examples/sandbox.py Mon Feb 16 17:04:18 2004
@@ -11,6 +11,10 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
+"""A small sandbox application.
+
+$Id$
+"""
import time, whrandom
from zope.interface import Interface, implements
@@ -218,7 +222,11 @@
try:
a.action()
except Exception, e:
- print a, h, e
+ print '-- Exception --'
+ print '"%s" in "%s" not allow to "%s"' %(a, h,
+ a._action.__name__)
+ print e
+ print
agents = filter(WanderLust, agents)
@@ -229,7 +237,10 @@
new_home = GreenerPastures(a)
home.transportAgent(a, new_home)
except Exception, e:
- print 'moving', a, h, new_home, e
+ print '-- Exception --'
+ print 'moving "%s" from "%s" to "%s"' %(a, h,` new_home`)
+ print e
+ print
def WanderLust(agent):
""" is agent ready to move """
=== Zope3/src/zope/security/examples/sandbox_security.py 1.7 => 1.8 ===
--- Zope3/src/zope/security/examples/sandbox_security.py:1.7 Sun Aug 17 02:09:25 2003
+++ Zope3/src/zope/security/examples/sandbox_security.py Mon Feb 16 17:04:18 2004
@@ -11,9 +11,13 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
+"""A small, secure sandbox application.
+
+$Id$
+"""
import sandbox
from zope.security.interfaces import ISecurityPolicy
-from zope.security import management, checker
+from zope.security import checker, management
from zope.interface import implements
#################################
@@ -134,8 +138,6 @@
management.setSecurityPolicy(SimulationSecurityPolicy())
- import zope.security.examples.sandbox
-
checker.defineChecker(sandbox.Sandbox, sandbox_checker)
checker.defineChecker(sandbox.TimeService, time_service_checker)
checker.defineChecker(sandbox.AgentDiscoveryService, agent_service_checker)
@@ -145,11 +147,11 @@
if not self._agents.has_key(agent.getId()) \
and sandbox.IAgent.isImplementedBy(agent):
self._agents[agent.getId()]=agent
- checker = checker.selectChecker(self)
- wrapped_home = checker.proxy(self)
+ agentChecker = checker.selectChecker(self)
+ wrapped_home = agentChecker.proxy(self)
agent.setHome(wrapped_home)
else:
- raise SandboxError("couldn't add agent %s"%agent)
+ raise sandbox.SandboxError("couldn't add agent %s"%agent)
sandbox.Sandbox.addAgent = addAgent
More information about the Zope3-Checkins
mailing list