1 Peak Security
Here's a brief example of how to use peak security.
1.1 A short example
#!python
from peak.api import *
class Owner(security.Permission):
pass
class Building(object):
security.allow(
burnBuilding = Owner
)
def burnBuilding(self):
print "Burn baby burn"
class buildingRules(security.RuleSet):
rules = Items(
checkCanBurn = [Owner.of(Building)]
)
def checkCanBurn(self, attempt):
if attempt.user is attempt.subject.owner:
return 1
else:
return security.Denial(
"You are not allowed to burn that building"
)
BuildingRules.declareRulesFor(security.IPermissionChecker)