Back to index

plone3  3.1.7
Public Member Functions
Archetypes.validator.AttributeValidator Class Reference
Inheritance diagram for Archetypes.validator.AttributeValidator:
Inheritance graph
Collaboration diagram for Archetypes.validator.AttributeValidator:
Collaboration graph

List of all members.

Public Member Functions

def __call__

Detailed Description

(Ab)Use the security policy implementation.

This class will be used to protect attributes managed by
AttributeStorage with the same permission as the accessor method.

It does so by abusing a feature of the security policy
implementation that the
'__allow_access_to_unprotected_subobjects__' attribute can be (0,
1) or a dictionary of {name: 0|1} or a callable instance taking
'name' and 'value' arguments.

The said attribute is accessed through getattr(), so by
subclassing from Implicit we get the accessed object as our

Next step is to check if the name is indeed a field name, and if
so, if it's using AttributeStorage, and if so, check the
read_permission against the object being accessed. All other cases
return '1' which means allow.

Definition at line 5 of file

Member Function Documentation

def Archetypes.validator.AttributeValidator.__call__ (   self,

Definition at line 27 of file

00028     def __call__(self, name, value):
00029         context = aq_parent(self)
00030         schema = context.Schema()
00031         if not schema.has_key(name):
00032             return 1
00033         field = schema[name]
00034         if not isinstance(field.getStorage(), AttributeStorage):
00035             return 1
00036         perm = field.read_permission
00037         if checkPerm(perm, context):
00038             return 1
00039         return 0

Here is the caller graph for this function:

The documentation for this class was generated from the following file: