def getPublicationAccreditation(object):
    from logging import getLogger
    log = getLogger('cs.accreditedfile.subscriber.getPublicationAccreditation')       

    putils = getToolByName(object, 'plone_utils')

    if object.expiration_date is None:
        # No expiration date, try finding it in parent
        parent = aq_parent(object)
        if parent.expiration_date is not None:
            object.expiration_date = parent.expiration_date
        else:
            # Uff, show error message
            putils.addPortalMessage(_(u'You have not set an expiration date for this file. Set it first and then try to get the accreditation using the menu'), type='warning')
            log.info('Not expiration date')
            return 

    result = accreditation(object)

    if result == 1:
        log.info('Accreditation correct')
        putils.addPortalMessage(_(u'Accreditation correct'), type='info')

    else:
        log.info('Error: %s' % result)
        putils.addPortalMessage(_(u'An error occurred getting the accreditation. Try again with the menu option: %(errorcode)s') % {'errorcode': result}, type='warning')
# -*- Message Factory Imported Here -*-
from cs.accreditedfile import accreditedfileMessageFactory as _
from cs.accreditedfile.interfaces import IAccreditedFile
from cs.accreditedfile.config import PROJECTNAME

AccreditedFileSchema = file.ATFileSchema.copy() + atapi.Schema((

    # -*- Your Archetypes field definitions here ... -*-
    atapi.StringField('url',
                      required=False,
                      searchable=True,
                      languageIndependent=True,
                      storage = atapi.AnnotationStorage(),
                      widget = atapi.StringWidget(
                               description = '',
                               label=_(u'label_url', default=u'Accreditation URL'),
                               visible={'view': 'visible', 'edit': 'invisible' } 
                               )
              ),
))

# Set storage on fields copied from ATContentTypeSchema, making sure
# they work well with the python bridge properties.

AccreditedFileSchema['title'].storage = atapi.AnnotationStorage()
AccreditedFileSchema['description'].storage = atapi.AnnotationStorage()

schemata.finalizeATCTSchema(AccreditedFileSchema, moveDiscussion=False)

# Move dates to main schemata. finalizeSchemata moves them to 'dates'
AccreditedFileSchema.changeSchemataForField('effectiveDate', 'default')