コード例 #1
0
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)
コード例 #2
0
 def available(self):
     if not (
         IATFile.providedBy(self.context) or
         IATBlobFile.providedBy(self.context)
         ):
         return False
     return bool(self.mission_report())
コード例 #3
0
 def available(self):
     if not (
         IATFile.providedBy(self.context) or 
         IATBlobFile.providedBy(self.context)
         ):
         return False
     return bool(self.consultant())
コード例 #4
0
ファイル: test_replacements.py プロジェクト: CGTIC/Plone_SP
 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?')
コード例 #5
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?')
コード例 #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
コード例 #7
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)
コード例 #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)
コード例 #9
0
 def available(self):
     if not (IATFile.providedBy(self.context)
             or IATBlobFile.providedBy(self.context)):
         return False
     return bool(self.mission_report())