def index(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: POST/GET variables of the request @type form: dict @return: a full page formatted in HTML @return: str ''' webapi.session_bareinit(req) session = webapi.get_session(req) pinfo = session['personinfo'] ulevel = pinfo['ulevel'] argd = wash_urlargd(form, {'ln': (str, CFG_SITE_LANG), 'recompute': (int, 0), 'verbose': (int, 0)}) ln = argd['ln'] debug = "verbose" in argd and argd["verbose"] > 0 # Create Page Markup and Menu cname = webapi.get_canonical_id_from_person_id(self.person_id) menu = WebProfileMenu(str(cname), "profile", ln, self._is_profile_owner(pinfo['pid']), self._is_admin(pinfo)) profile_page = WebProfilePage("profile", webapi.get_longest_name_from_pid(self.person_id)) profile_page.add_profile_menu(menu) gboxstatus = self.person_id gpid = self.person_id gNumOfWorkers = 3 # to do: read it from conf file gReqTimeout = 5000 gPageTimeout = 120000 profile_page.add_bootstrapped_data(json.dumps({ "other": "var gBOX_STATUS = '%s';var gPID = '%s'; var gNumOfWorkers= '%s'; var gReqTimeout= '%s'; var gPageTimeout= '%s';" % (gboxstatus, gpid, gNumOfWorkers, gReqTimeout, gPageTimeout), "backbone": """ (function(ticketbox) { var app = ticketbox.app; app.userops.set(%s); app.bodyModel.set({userLevel: "%s"}); })(ticketbox);""" % (WebInterfaceAuthorTicketHandling.bootstrap_status(pinfo, "user"), ulevel) })) if debug: profile_page.add_debug_info(pinfo) 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 CFG_WEBAUTHORPROFILE_USE_BIBAUTHORID: if self.person_id < 0: return redirect_to_url(req, '%s/author/search?q=%s%s' % (CFG_SITE_URL, self.original_search_parameter, encoded)) else: self.person_id = self.original_search_parameter assert not form.has_key('jsondata'), "Content type should be only text/html." title_message = 'Author Publication Profile Page' expire_cache = False if argd['recompute'] and req.get_method() == 'POST': expire_cache = True content = self.create_authorpage_websearch(req, form, ln, expire_cache) history_log_visit(req, 'profile', pid = self.person_id) if isinstance(content, dict): meta = profile_page.get_head() + content['head'] body = profile_page.get_wrapped_body(content['body']) return page(title=title_message, metaheaderadd=meta.encode('utf-8'), body=body.encode('utf-8'), req=req, language=ln, show_title_p=False) else: return page(title=title_message, metaheaderadd="", body="Error, no content returned!".encode('utf-8'), req=req, language=ln, show_title_p=False)
def index(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: POST/GET variables of the request @type form: dict @return: a full page formatted in HTML @return: str ''' webapi.session_bareinit(req) session = webapi.get_session(req) pinfo = session['personinfo'] ulevel = pinfo['ulevel'] argd = wash_urlargd( form, { 'ln': (str, CFG_SITE_LANG), 'recompute': (int, 0), 'verbose': (int, 0), 'trial': (str, None) }) ln = argd['ln'] debug = "verbose" in argd and argd["verbose"] > 0 # Create Page Markup and Menu try: int(self.person_id) except ValueError: cname = self.person_id else: cname = webapi.get_canonical_id_from_person_id(self.person_id) menu = WebProfileMenu(str(cname), "profile", ln, self._is_profile_owner(pinfo['pid']), self._is_admin(pinfo)) profile_page = WebProfilePage( "profile", webapi.get_longest_name_from_pid(self.person_id)) profile_page.add_profile_menu(menu) if 'form_email' in pinfo: gFormEmail = pinfo['form_email'] else: gFormEmail = "" profile_page.add_bootstrapped_data( json.dumps({ "backbone": """ (function(ticketbox) { var app = ticketbox.app; app.userops.set(%s); app.bodyModel.set({userLevel: "%s"}); })(ticketbox);""" % (WebInterfaceAuthorTicketHandling.bootstrap_status( pinfo, "user"), ulevel), "other": "var gUserLevel = '%s'; var gFormEmail = '%s';" % (ulevel, gFormEmail) })) if debug: profile_page.add_debug_info(pinfo) last_computed = str(self.last_computed()) context = { 'person_id': self.person_id, 'last_computed': last_computed, 'citation_fine_print_link': "%s/help/citation-metrics" % CFG_BASE_URL, 'search_form_url': "%s/author/search" % CFG_BASE_URL, 'possible_to_recompute': self._possible_to_recompute(pinfo) } 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 CFG_BIBAUTHORID_ENABLED: if self.person_id < 0: return redirect_to_url( req, '%s/author/search?q=%s%s' % (CFG_SITE_URL, self.original_search_parameter, encoded)) else: self.person_id = self.original_search_parameter profile_page.menu = None assert not form.has_key( 'jsondata'), "Content type should be only text/html." full_name = webapi.get_longest_name_from_pid(self.person_id) page_title = '%s - Profile' % full_name if argd['recompute'] and req.get_method() == 'POST': expire_all_cache_for_person(self.person_id) context['last_computed'] = str( datetime.now().replace(microsecond=0)) history_log_visit(req, 'profile', pid=self.person_id) meta = profile_page.get_head() context["visible"] = AID_VISIBILITY context["element_width"] = self.render_width_dict body = profile_page.get_wrapped_body("profile_page", context) return page(title=page_title, metaheaderadd=meta.encode('utf-8'), body=body.encode('utf-8'), req=req, language=ln, show_title_p=False)
def index(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: POST/GET variables of the request @type form: dict @return: a full page formatted in HTML @return: str ''' webapi.session_bareinit(req) session = webapi.get_session(req) pinfo = session['personinfo'] ulevel = pinfo['ulevel'] argd = wash_urlargd(form, { 'ln': (str, CFG_SITE_LANG), 'recompute': (int, 0), 'verbose': (int, 0) }) ln = argd['ln'] debug = "verbose" in argd and argd["verbose"] > 0 # Create Page Markup and Menu cname = webapi.get_canonical_id_from_person_id(self.person_id) menu = WebProfileMenu(str(cname), "profile", ln, self._is_profile_owner(pinfo['pid']), self._is_admin(pinfo)) profile_page = WebProfilePage( "profile", webapi.get_longest_name_from_pid(self.person_id)) profile_page.add_profile_menu(menu) gboxstatus = self.person_id gpid = self.person_id gNumOfWorkers = 3 # to do: read it from conf file gReqTimeout = 5000 gPageTimeout = 120000 profile_page.add_bootstrapped_data( json.dumps({ "other": "var gBOX_STATUS = '%s';var gPID = '%s'; var gNumOfWorkers= '%s'; var gReqTimeout= '%s'; var gPageTimeout= '%s';" % (gboxstatus, gpid, gNumOfWorkers, gReqTimeout, gPageTimeout), "backbone": """ (function(ticketbox) { var app = ticketbox.app; app.userops.set(%s); app.bodyModel.set({userLevel: "%s"}); })(ticketbox);""" % (WebInterfaceAuthorTicketHandling.bootstrap_status( pinfo, "user"), ulevel) })) if debug: profile_page.add_debug_info(pinfo) 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 CFG_WEBAUTHORPROFILE_USE_BIBAUTHORID: if self.person_id < 0: return redirect_to_url( req, '%s/author/search?q=%s%s' % (CFG_SITE_URL, self.original_search_parameter, encoded)) else: self.person_id = self.original_search_parameter assert not form.has_key( 'jsondata'), "Content type should be only text/html." title_message = 'Author Publication Profile Page' expire_cache = False if argd['recompute'] and req.get_method() == 'POST': expire_cache = True content = self.create_authorpage_websearch(req, form, ln, expire_cache) history_log_visit(req, 'profile', pid=self.person_id) if isinstance(content, dict): meta = profile_page.get_head() + content['head'] body = profile_page.get_wrapped_body(content['body']) return page(title=title_message, metaheaderadd=meta.encode('utf-8'), body=body.encode('utf-8'), req=req, language=ln, show_title_p=False) else: return page(title=title_message, metaheaderadd="", body="Error, no content returned!".encode('utf-8'), req=req, language=ln, show_title_p=False)