Logo Search packages:      
Sourcecode: zope-cmfbibliographyat version File versions  Download package

def CMFBibliographyAT::content::base::BaseEntry::inferAuthorReferences (   self,
  report_mode = 'v' 
)

If the item has no author references set but the tool suppors
member referencesw or the site
uses CMFMember, it tries to find a content object croresponding
to the author name and makes reference there.

Lookup is done on firstname lastname match.

A report is returned controlled by the mode:

- 'v': verbose; the default; for each author it is indicated
       what was done.
- 'q': quiet; nothing is returned
- 'c': conflicts only; conflicts occur if several potential
       target members are found

Definition at line 244 of file base.py.

00244                                                     :
        """
        If the item has no author references set but the tool suppors
        member referencesw or the site
        uses CMFMember, it tries to find a content object croresponding
        to the author name and makes reference there.
        
        Lookup is done on firstname lastname match.
        
        A report is returned controlled by the mode:

        - 'v': verbose; the default; for each author it is indicated
               what was done.
        - 'q': quiet; nothing is returned
        - 'c': conflicts only; conflicts occur if several potential
               target members are found
        """
        if not self.showMemberAuthors() or \
               self.usesCMFMember()or \
               self.getMember_publication_authors():
            return "No inference attempted"
        report = []
        authors = []
        a_modified = False
        md = getToolByName(self, 'portal_memberdata')
        bib_tool = getToolByName(self, 'portal_bibliography')
        membertypes = bib_tool.getProperty('member_types') or \
                      md.getAllowedMemberTypes()
        catalog = getToolByName(self, 'portal_catalog')
        for author in self.getAuthors():
            authors.append(author)
            last = author.get('lastname', None)
            if last is None:
                continue
            candidates = catalog(portal_type=membertypes,
                                 Title=last)
            if not candidates:
                msg = "%s: no corresponding member found." % author()
                if report_mode == 'v':
                    report.append(msg)
            elif len(candidates) > 1:
                msg = "%s: several corresponding members found:" % author()
                for c in candidates:
                    msg += " %s at %s," % (c.Title, c.getURL(relative=1))
                report.append(msg)
            else:
                target = candidates[0].getObject()
                name = target.Title()
                if not name.startswith(author.get('firstname')) \
                   or not name.endswith(author.get('lastname')):
                    msg = "%s: no corresponding member found." % author()
                    continue
                self.addReference(target, 'authorOf')
                author['reference'] = target.UID()
                a_modified = True
                msg = "%s: referring to %s at %s." \
                      % (author(),
                         name,
                         target.absolute_url(relative=1),
                         )
                if report_mode == 'v':
                    report.append(msg)
        if a_modified:
            self.setAuthors(authors)
        if report_mode != 'q' and report:
            ## report.insert(0, "%s:\n" % self.absolute_url(relative=1))
            return ' '.join(report)
        return None

    security.declareProtected(View, 'getPublicationDate')
    def getPublicationDate(self):


Generated by  Doxygen 1.6.0   Back to index