Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes
CMFEditions.StandardModifiers.AbortVersioningOfLargeFilesAndImages Class Reference
Inheritance diagram for CMFEditions.StandardModifiers.AbortVersioningOfLargeFilesAndImages:
Inheritance graph
[legend]
Collaboration diagram for CMFEditions.StandardModifiers.AbortVersioningOfLargeFilesAndImages:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def edit
def getFieldNames
def getModifier
def getOnCloneModifiers

Public Attributes

 id
 title
 meta_type
 max_size
 field_names

Static Public Attributes

tuple field_names = ('file', 'image')
int max_size = 26214400
tuple modifierEditForm

Private Member Functions

def _getFieldValues

Private Attributes

 _enabled

Static Private Attributes

tuple __implements__ = (IConditionalTalesModifier, ICloneModifier,)
tuple _condition = Expression("python: portal_type in ('Image', 'File')")

Detailed Description

Raises an error if a file or image attribute stored on the
object in a specified field is larger than a fixed default

Definition at line 711 of file StandardModifiers.py.


Constructor & Destructor Documentation

Definition at line 727 of file StandardModifiers.py.

00727 
00728                  title=''):
00729         self.id = str(id)
00730         self.title = str(title)
00731         self.meta_type = 'edmod_%s' % id
00732         self._enabled = False


Member Function Documentation

Finds the specified field values and returns them if
they contain file objects which are too large.  Specifically,
it returns an iterator of tuples containing the type of storage,
the field name, and the value stored

Definition at line 753 of file StandardModifiers.py.

00753 
00754     def _getFieldValues(self, obj):
00755         """Finds the specified field values and returns them if
00756         they contain file objects which are too large.  Specifically,
00757         it returns an iterator of tuples containing the type of storage,
00758         the field name, and the value stored"""
00759         max_size  = self.max_size
00760 
00761         # Search for fields stored via AnnotationStorage
00762         annotations = getattr(obj, '__annotations__', None)
00763         if annotations is not None:
00764             annotation_names = (ANNOTATION_PREFIX + name for name in
00765                                                               self.field_names)
00766             for name in annotation_names:
00767                 val = annotations.get(name, None)
00768                 # Skip linked Pdata chains too long for the pickler
00769                 if hasattr(aq_base(val), 'getSize') and callable(val.getSize):
00770                     size = val.getSize()
00771                     if isinstance(size, (int, long)) and size >= max_size:
00772                         yield 'annotation', name, val
00773 
00774         # Search for fields stored via AttributeStorage
00775         for name in self.field_names:
00776             val = getattr(obj, name, None)
00777             # Skip linked Pdata chains too long for the pickler
00778             if hasattr(aq_base(val), 'getSize') and callable(val.getSize):
00779                 size = val.getSize()
00780                 if isinstance(size, int) and size >= max_size:
00781                     yield 'attribute', name, val

Here is the caller graph for this function:

def CMFEditions.StandardModifiers.AbortVersioningOfLargeFilesAndImages.edit (   self,
  enabled = None,
  condition = None,
  title = '',
  field_names = None,
  max_size = None,
  REQUEST = None 
)
See IConditionalTalesModifier.

Definition at line 734 of file StandardModifiers.py.

00734 
00735              max_size=None, REQUEST=None):
00736         """See IConditionalTalesModifier.
00737         """
00738         if max_size is not None:
00739             self.max_size = int(max_size)
00740         if field_names is not None:
00741             field_names = tuple(s.strip() for s in field_names.split('\n') if s)
00742             if field_names != self.field_names:
00743                 self.field_names = field_names
00744         return ConditionalTalesModifier.edit(self, enabled, condition, title)

Here is the caller graph for this function:

For the edit form

Definition at line 745 of file StandardModifiers.py.

00745 
00746     def getFieldNames(self):
00747         """For the edit form"""
00748         return '\n'.join(self.field_names)

We are the modifier, not some silly wrapper. 

Definition at line 749 of file StandardModifiers.py.

00749 
00750     def getModifier(self):
00751         """We are the modifier, not some silly wrapper. """
00752         return self

Detects large file objects and raises an error

Reimplemented in CMFEditions.StandardModifiers.SkipVersioningOfLargeFilesAndImages.

Definition at line 782 of file StandardModifiers.py.

00782 
00783     def getOnCloneModifiers(self, obj):
00784         """Detects large file objects and raises an error
00785         """
00786         for storage, name, val in self._getFieldValues(obj):
00787             # if we find a file that's too big, abort
00788             raise FileTooLargeToVersionError
00789         return None # no effect otherwise
00790 
00791 InitializeClass(AbortVersioningOfLargeFilesAndImages)

Here is the call graph for this function:


Member Data Documentation

tuple CMFEditions.StandardModifiers.AbortVersioningOfLargeFilesAndImages.__implements__ = (IConditionalTalesModifier, ICloneModifier,) [static, private]
tuple CMFEditions.StandardModifiers.AbortVersioningOfLargeFilesAndImages._condition = Expression("python: portal_type in ('Image', 'File')") [static, private]

Definition at line 724 of file StandardModifiers.py.

Definition at line 731 of file StandardModifiers.py.

Definition at line 715 of file StandardModifiers.py.

Definition at line 742 of file StandardModifiers.py.

Definition at line 728 of file StandardModifiers.py.

Definition at line 716 of file StandardModifiers.py.

Definition at line 738 of file StandardModifiers.py.

Definition at line 730 of file StandardModifiers.py.

Initial value:
PageTemplateFile('www/fieldModifierEditForm.pt',
                                        globals(),
                                        __name__='modifierEditForm')

Definition at line 720 of file StandardModifiers.py.

Definition at line 729 of file StandardModifiers.py.


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