def generate(self):
        note = self.note
        results = []

        if note.format:
            # a format is defined, we query for the selected utility to
            # generate the values below.
            u = zope.component.queryUtility(ICitationFormat, name=note.format)
            if u is None:
                # Something is wrong, either bad data or utility 
                # disappeared on us.  Fallback to the next step.
                pass
            else:
                # this may also provide the license_path if it has been
                # correctly added to the site.
                license_path, dcterms_license = u(self.context)()
                results.append(('license_path', license_path,))
                results.append(('dcterms_license', dcterms_license,))
                return results

        if note.license_path:
            license = getLicenses(self.context, path=note.license_path)
            if license:
                results.append(('dcterms_license', 
                                license[0].pmr2_license_uri,))
        return results
 def __init__(self, context):
     self.context = context
     self.pt = None
     try:
         ctx = self.context
         # Since this is primarily used within notes, we check to see
         # whether to pass its parent (the ExposureFile) to get the
         # list of licenses.
         # XXX might a check for IContained/ILocated(?) be better?
         if IExposureFileNote.providedBy(ctx):
             ctx = ctx.__parent__
         elif IPMR2GlobalSettings.providedBy(ctx):
             ctx = ctx.__parent__
         elif IPluginSettings.providedBy(ctx):
             ctx = ctx.__parent__.__parent__
         values = getLicenses(ctx)
     except:
         values = []
     terms = [SimpleTerm(v.getPath(), v.Title) for v in values]
     super(LicenseType, self).__init__(terms)