Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Private Attributes
ATContentTypes.lib.validators.NonEmptyFileValidator Class Reference

List of all members.

Public Member Functions

def __init__
def __call__

Public Attributes

 name
 title
 description

Static Private Attributes

 __implements__ = IValidator

Detailed Description

Fails on empty non-existant files

Definition at line 181 of file validators.py.


Constructor & Destructor Documentation

def ATContentTypes.lib.validators.NonEmptyFileValidator.__init__ (   self,
  name,
  title = '',
  description = '' 
)

Definition at line 187 of file validators.py.

00187 
00188     def __init__(self, name, title='', description=''):
00189         self.name = name
00190         self.title = title or name
00191         self.description = description


Member Function Documentation

def ATContentTypes.lib.validators.NonEmptyFileValidator.__call__ (   self,
  value,
  args,
  kwargs 
)

Definition at line 192 of file validators.py.

00192 
00193     def __call__(self, value, *args, **kwargs):
00194         instance = kwargs.get('instance', None)
00195         field    = kwargs.get('field', None)
00196 
00197         # calculate size
00198         if isinstance(value, FileUpload) or type(value) is FileType \
00199           or hasattr(aq_base(value), 'tell'):
00200             value.seek(0, 2) # eof
00201             size = value.tell()
00202             value.seek(0)
00203         else:
00204             try:
00205                 size = len(value)
00206             except TypeError:
00207                 size = 1
00208 
00209         if size == 0:
00210             return ("Validation failed: Uploaded file is empty")
00211         else:
00212             return True
00213 
00214 
00215 validatorList.append(NonEmptyFileValidator('isNonEmptyFile', title='', description=''))

Here is the caller graph for this function:


Member Data Documentation

Definition at line 185 of file validators.py.

Definition at line 190 of file validators.py.

Definition at line 188 of file validators.py.

Definition at line 189 of file validators.py.


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