Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Private Attributes
validation.validators.EmptyValidator.EmptyValidator Class Reference

List of all members.

Public Member Functions

def __init__
def __call__

Public Attributes

 name
 title
 description
 showError

Static Private Attributes

 __implements__ = IValidator

Detailed Description

Definition at line 17 of file EmptyValidator.py.


Constructor & Destructor Documentation

def validation.validators.EmptyValidator.EmptyValidator.__init__ (   self,
  name,
  title = '',
  description = '',
  showError = True 
)

Definition at line 20 of file EmptyValidator.py.

00020 
00021     def __init__(self, name, title='', description='', showError=True):
00022         self.name = name
00023         self.title = title or name
00024         self.description = description
00025         self.showError = showError


Member Function Documentation

def validation.validators.EmptyValidator.EmptyValidator.__call__ (   self,
  value,
  args,
  kwargs 
)

Definition at line 26 of file EmptyValidator.py.

00026 
00027     def __call__(self, value, *args, **kwargs):
00028         isEmpty  = kwargs.get('isEmpty', False)
00029         instance = kwargs.get('instance', None)
00030         field    = kwargs.get('field', None)
00031 
00032         # XXX: This is a temporary fix. Need to be fixed right for AT 2.0
00033         #      content_edit / BaseObject.processForm() calls
00034         #      widget.process_form a second time!
00035         if instance and field:
00036             widget  = field.widget
00037             request = getattr(instance, 'REQUEST', None)
00038             if request and request.form:
00039                 form   = request.form
00040                 result = widget.process_form(instance, field, form,
00041                                              empty_marker=_marker,
00042                                              emptyReturnsMarker=True)
00043                 if result is _marker or result is None:
00044                     isEmpty = True
00045 
00046         if isEmpty:
00047             return True
00048         elif value == '' or value is None:
00049             return True
00050         else:
00051             if getattr(self, 'showError', False):
00052                 return ("Validation failed(%(name)s): '%(value)s' is not empty." %
00053                        { 'name' : self.name, 'value': value})
00054             else:
00055                 return False


Member Data Documentation

Definition at line 18 of file EmptyValidator.py.

Definition at line 23 of file EmptyValidator.py.

Definition at line 21 of file EmptyValidator.py.

Definition at line 24 of file EmptyValidator.py.

Definition at line 22 of file EmptyValidator.py.


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