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

def CMFBibliographyAT::content::base::BaseEntry::getAuthorURL (   self,
  author 
)

finds the URL of the author's hompage
First, looks if 'homepage' is set in the 'author' dictionary
Second, asks the tool for an entry for 'firstname' + 'lastname'
Third, asks the membership tool whether there is a user 'lastname'

Definition at line 120 of file base.py.

00120                                   :
        """
        finds the URL of the author's hompage
        First, looks if 'homepage' is set in the 'author' dictionary
        Second, asks the tool for an entry for 'firstname' + 'lastname'
        Third, asks the membership tool whether there is a user 'lastname'
        """
        # 1. on object base
        homepage = author.get('homepage', None)
        if homepage: return homepage

        # 2. on bibfolder base
        parent = self.aq_parent
        full_name = author.get('firstname', '') \
                    + ' ' \
                    + author.get('lastname', '')

        if parent.meta_type == 'BibliographyFolder':
            homepage = parent.AuthorURLs().get(full_name.strip(), None)
        if homepage: return homepage

        # 3. Site wide look-up by fullname
        membertool = getToolByName(self, 'portal_membership', None)
        full_names = [m.getProperty('fullname', 'dummy') \
                      for m in membertool.listMembers()]
        try:
            index = full_names.index(full_name)
            user = membertool.listMembers()[index].getId()
            return membertool.getHomeUrl(user, 1)
        except ValueError:
            pass

        # 4. Site wide look-up by first initial plus lastname

        fname = author.get('firstname', '')
        lname = author.get('lastname', '')
        abbrev_name = ''
        if fname: abbrev_name += fname + ' '
        abbrev_name += lname
        abbrev_name = abbrev_name.strip()

        abbrev_names = []
        for name in full_names:
            tokens = name.split()
            if len(tokens) > 1:
                aname = tokens[0][0] + ' ' + tokens[-1]
            else:
                aname = name
            abbrev_names.append(aname)
        try:
            index = abbrev_names.index(abbrev_name)
            user = membertool.listMembers()[index].getId()
            return membertool.getHomeUrl(user, 1)
        except ValueError:
            pass


        # 5. admittedly stupid default
        user = author.get('lastname', '').lower()
        homepage = membertool.getHomeUrl(user, 1)

        return homepage

    security.declareProtected(View, 'getURL')
    def getURL(self, defaultURL=None):


Generated by  Doxygen 1.6.0   Back to index