def markNewContentObject(obj, event):
    """Mark newly created content as Pigeonhole-aware if its 
    portal type is in our list of Aware types"""

    # get our local utility
    # this is incidentally also our lame check
    # to see if PH is installed here
    try:
        utility = getUtility(IPigeonholizer)
    except ComponentLookupError:
        # ignore problems when we can't find the utility -- PH might not
        # be installed
        utility = None
    if utility is not None:
        if obj.portal_type in utility.ph_aware_types:
            alsoProvides(obj, IPigeonholeAware)
        elif blobsAvailable:
            # in Plone 3, the meta_type for blob-based Images and Files
            # is just ATBlob, but thanks to a custom factory, they DO have
            # marker interfaces set. Check them!
            if "Image" in utility.ph_aware_types and \
                IATBlobImage.providedBy(obj):
                alsoProvides(obj, IPigeonholeAware)
            elif "File" in utility.ph_aware_types and \
                IATBlobFile.providedBy(obj):
                alsoProvides(obj, IPigeonholeAware)
        if disableCache is not None:
            disableCache(getSite().REQUEST)
 def available(self):
     if not (
         IATFile.providedBy(self.context) or
         IATBlobFile.providedBy(self.context)
         ):
         return False
     return bool(self.mission_report())
 def available(self):
     if not (
         IATFile.providedBy(self.context) or 
         IATBlobFile.providedBy(self.context)
         ):
         return False
     return bool(self.consultant())
Exemple #4
0
 def testFileBlobInterfaces(self):
     foo = self.folder[self.folder.invokeFactory('File', 'foo')]
     self.assertTrue(atfile.IATFile.providedBy(foo), 'no IATFile?')
     self.assertTrue(atfile.IFileContent.providedBy(foo), 'no IFileContent?')
     self.assertTrue(IATBlobFile.providedBy(foo), 'no IATBlobFile?')
     if not IInterface.providedBy(Z2IATFile):    # this is zope < 2.12
         self.assertTrue(Z2IATFile.isImplementedBy(foo), 'no zope2 IATFile?')
         self.assertFalse(Z2IATImage.isImplementedBy(foo), 'zope2 IATImage?')
 def testFileBlobInterfaces(self):
     foo = self.folder[self.folder.invokeFactory('File', 'foo')]
     self.assertTrue(atfile.IATFile.providedBy(foo), 'no IATFile?')
     self.assertTrue(atfile.IFileContent.providedBy(foo), 'no IFileContent?')
     self.assertTrue(IATBlobFile.providedBy(foo), 'no IATBlobFile?')
     if not IInterface.providedBy(Z2IATFile):    # this is zope < 2.12
         self.assertTrue(Z2IATFile.isImplementedBy(foo), 'no zope2 IATFile?')
         self.assertFalse(Z2IATImage.isImplementedBy(foo), 'zope2 IATImage?')
Exemple #6
0
 def __repr__(self):
     """ try to mimic the the old file and image types from ATCT
         for improved test compatibility """
     res = super(ATBlob, self).__repr__()
     if IATBlobFile.providedBy(self):
         res = res.replace(ATBlob.__name__, 'ATFile', 1)
     elif IATBlobImage.providedBy(self):
         res = res.replace(ATBlob.__name__, 'ATImage', 1)
     return res
 def set(self, instance, value, **kwargs):
     super(BlobFileField, self).set(instance, value, **kwargs)
     if not kwargs.get('_initializing_', False) and (IATBlobFile.providedBy(instance) or isinstance(instance, ATFile)):
         self.fixAutoId(instance)
Exemple #8
0
 def set(self, instance, value, **kwargs):
     super(BlobFileField, self).set(instance, value, **kwargs)
     if not kwargs.get('_initializing_',
                       False) and (IATBlobFile.providedBy(instance)
                                   or isinstance(instance, ATFile)):
         self.fixAutoId(instance)
Exemple #9
0
 def available(self):
     if not (IATFile.providedBy(self.context)
             or IATBlobFile.providedBy(self.context)):
         return False
     return bool(self.mission_report())