Guest User

Untitled

a guest
Jul 19th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. from zope.component import adapts
  2. from zope.interface import implements
  3. from archetypes.schemaextender.interfaces import ISchemaExtender
  4. from archetypes.schemaextender.field import ExtensionField
  5.  
  6. from Products.Archetypes.atapi import FileWidget, FileField, AnnotationStorage
  7. from Products.ATContentTypes.interfaces import IATFile
  8. from Products.validation import V_REQUIRED
  9. from Products.ATContentTypes import ATCTMessageFactory as _
  10.  
  11. class VirusFreeFileField(ExtensionField, FileField):
  12. """ derivative of blobfield for extending schemas """
  13. pass
  14.  
  15. class VirusFreeATFileExtender(object):
  16. """
  17. """
  18. adapts(IATFile)
  19. implements(ISchemaExtender)
  20. fields = [
  21. VirusFreeFileField('file',
  22. required=True,
  23. primary=True,
  24. searchable=True,
  25. languageIndependent=True,
  26. storage = AnnotationStorage(migrate=True),
  27. validators = (('isNonEmptyFile', V_REQUIRED),
  28. ('checkFileMaxSize', V_REQUIRED),
  29. ('isVirusFree', V_REQUIRED),),
  30. widget = FileWidget(
  31. description = '',
  32. label=_(u'label_file', default=u'File'),
  33. show_content_type = False,)
  34. ),
  35. ]
  36. def __init__(self, context):
  37. self.context = context
  38. def getFields(self):
  39. return self.fields
Add Comment
Please, Sign In to add comment