def __call__(self, req, form): ''' Serves the main person page. Will use the object's person id to get a person's information. @param req: apache request object @type req: apache request object @param form: POST/GET variables of the request @type form: dict @return: a full page formatted in HTML @rtype: str ''' if not CFG_WEBAUTHORPROFILE_USE_BIBAUTHORID: self.person_id = self.original_search_parameter return self.index(req, form) argd = wash_urlargd(form, {'ln': (str, CFG_SITE_LANG), 'recid': (int, -1), 'verbose': (int, 0)}) ln = argd['ln'] verbose = argd['verbose'] url_args = dict() if ln != CFG_SITE_LANG: url_args['ln'] = ln if verbose: url_args['verbose'] = str(verbose) encoded = urlencode(url_args) if encoded: encoded = '?' + encoded if self.cid is not None and self.original_search_parameter != self.cid: return redirect_to_url(req, '%s/author/profile/%s%s' % (CFG_SITE_URL, self.cid, encoded)) # author may have only author identifier and not a canonical id if self.person_id > -1: return self.index(req, form) recid = argd['recid'] if recid > -1: possible_authors = search_person_ids_by_name(self.original_search_parameter, limit_to_recid = recid) if len(possible_authors) == 1: self.person_id = possible_authors[0][0] self.cid = get_person_redirect_link(self.person_id) redirect_to_url(req, '%s/author/profile/%s%s' % (CFG_SITE_URL, self.cid, encoded)) encoded = urlencode(url_args) if encoded: encoded = '&' + encoded return redirect_to_url(req, '%s/author/search?q=%s%s' % (CFG_SITE_URL, self.original_search_parameter, encoded))
def __call__(self, req, form): ''' Serve the main person page. Will use the object's person id to get a person's information. @param req: Apache Request Object @type req: Apache Request Object @param form: Parameters sent via GET or POST request @type form: dict @return: a full page formatted in HTML @return: string ''' argd = wash_urlargd(form, {'ln': (str, CFG_SITE_LANG), 'verbose': (int, 0), 'recid': (int, -1) }) recid = argd['recid'] if not CFG_WEBAUTHORPROFILE_USE_BIBAUTHORID: return self.index(req, form) if self.cid: return redirect_to_url(req, '%s/author/%s/' % (CFG_SITE_URL, self.cid)) elif self.person_id and self.person_id >= 0: return redirect_to_url(req, '%s/author/%s/' % (CFG_SITE_URL, self.person_id)) elif self.person_id and recid > -1: #we got something different from person_id, canonical name or bibrefrec pair. #try to figure out a personid argd = wash_urlargd(form, {'ln': (str, CFG_SITE_LANG), 'verbose': (int, 0), 'recid': (int, -1) }) recid = argd['recid'] if not recid: return redirect_to_url(req, "%s/person/search?q=%s" % (CFG_SITE_URL, self.original_search_parameter)) # req.write("Not enough search parameters %s"% # str(self.original_search_parameter)) nquery = self.original_search_parameter sorted_results = search_person_ids_by_name(nquery) test_results = None authors = [] for results in sorted_results: pid = results[0] authorpapers = get_papers_by_person_id(pid, -1) authorpapers = sorted(authorpapers, key=itemgetter(0), reverse=True) if (recid and not (str(recid) in [row[0] for row in authorpapers])): continue authors.append([results[0], results[1], authorpapers[0:4]]) test_results = authors if len(test_results) == 1: self.person_id = test_results[0][0] self.cid = get_person_redirect_link(self.person_id) if self.cid and self.person_id > -1: redirect_to_url(req, '%s/author/%s/' % (CFG_SITE_URL, self.cid)) elif self.person_id > -1: redirect_to_url(req, '%s/author/%s/' % (CFG_SITE_URL, self.person_id)) else: return redirect_to_url(req, "%s/person/search?q=%s" % (CFG_SITE_URL, self.original_search_parameter)) #req.write("Could not determine personID from bibrec. What to do here? %s"% #str(self.original_search_parameter)) else: return redirect_to_url(req, "%s/person/search?q=%s" % (CFG_SITE_URL, self.original_search_parameter)) #req.write("Could not determine personID from bibrec. What to do here 2? %s"% # (str(self.original_search_parameter),str(recid))) else: return redirect_to_url(req, "%s/person/search?q=%s" % (CFG_SITE_URL, self.original_search_parameter))
def __call__(self, req, form): ''' Serves the main person page. Will use the object's person id to get a person's information. @param req: apache request object @type req: apache request object @param form: POST/GET variables of the request @type form: dict @return: a full page formatted in HTML @rtype: str ''' if not CFG_WEBAUTHORPROFILE_USE_BIBAUTHORID: self.person_id = self.original_search_parameter return self.index(req, form) argd = wash_urlargd(form, { 'ln': (str, CFG_SITE_LANG), 'recid': (int, -1), 'verbose': (int, 0) }) ln = argd['ln'] verbose = argd['verbose'] url_args = dict() if ln != CFG_SITE_LANG: url_args['ln'] = ln if verbose: url_args['verbose'] = str(verbose) encoded = urlencode(url_args) if encoded: encoded = '?' + encoded if self.cid is not None and self.original_search_parameter != self.cid: return redirect_to_url( req, '%s/author/profile/%s%s' % (CFG_SITE_URL, self.cid, encoded)) # author may have only author identifier and not a canonical id if self.person_id > -1: return self.index(req, form) recid = argd['recid'] if recid > -1: possible_authors = search_person_ids_by_name( self.original_search_parameter, limit_to_recid=recid) if len(possible_authors) == 1: self.person_id = possible_authors[0][0] self.cid = get_person_redirect_link(self.person_id) redirect_to_url( req, '%s/author/profile/%s%s' % (CFG_SITE_URL, self.cid, encoded)) encoded = urlencode(url_args) if encoded: encoded = '&' + encoded return redirect_to_url( req, '%s/author/search?q=%s%s' % (CFG_SITE_URL, self.original_search_parameter, encoded))