本文整理汇总了Python中invenio.config.CFG_SITE_NAME_INTL类的典型用法代码示例。如果您正苦于以下问题:Python CFG_SITE_NAME_INTL类的具体用法?Python CFG_SITE_NAME_INTL怎么用?Python CFG_SITE_NAME_INTL使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CFG_SITE_NAME_INTL类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update
def update(self, req, form):
argd = wash_urlargd(
form,
{
"name": (str, None),
"freq": (str, None),
"notif": (str, None),
"idb": (int, None),
"idq": (int, None),
"old_idb": (int, None),
},
)
uid = getUid(req)
if CFG_ACCESS_CONTROL_LEVEL_SITE >= 1:
return page_not_authorized(req, "%s/youralerts/update" % (CFG_SITE_SECURE_URL,), navmenuid="youralerts")
elif uid == -1 or isGuestUser(uid):
return redirect_to_url(
req,
"%s/youraccount/login%s"
% (
CFG_SITE_SECURE_URL,
make_canonical_urlargd(
{
"referer": "%s/youralerts/update%s"
% (CFG_SITE_SECURE_URL, make_canonical_urlargd(argd, {})),
"ln": argd["ln"],
},
{},
),
),
)
# load the right language
_ = gettext_set_language(argd["ln"])
user_info = collect_user_info(req)
if not user_info["precached_usealerts"]:
return page_not_authorized(req, "../", text=_("You are not authorized to use alerts."))
try:
html = webalert.perform_update_alert(
argd["name"], argd["freq"], argd["notif"], argd["idb"], argd["idq"], argd["old_idb"], uid, ln=argd["ln"]
)
except webalert.AlertError, msg:
return page(
title=_("Error"),
body=webalert_templates.tmpl_errorMsg(ln=argd["ln"], error_msg=msg),
navtrail="""<a class="navtrail" href="%(sitesecureurl)s/youraccount/display?ln=%(ln)s">%(account)s</a>"""
% {"sitesecureurl": CFG_SITE_SECURE_URL, "ln": argd["ln"], "account": _("Your Account")},
description=_("%s Personalize, Set a new alert") % CFG_SITE_NAME_INTL.get(argd["ln"], CFG_SITE_NAME),
keywords=_("%s, personalize") % CFG_SITE_NAME_INTL.get(argd["ln"], CFG_SITE_NAME),
uid=uid,
language=argd["ln"],
req=req,
lastupdated=__lastupdated__,
navmenuid="youralerts",
)
示例2: display
def display(self, req, form):
"""Display search history page. A misnomer."""
argd = wash_urlargd(form, {'p': (str, "n")
})
uid = getUid(req)
# load the right language
_ = gettext_set_language(argd['ln'])
if CFG_ACCESS_CONTROL_LEVEL_SITE >= 1:
return page_not_authorized(req, "%s/youralerts/display" % \
(CFG_SITE_URL,),
navmenuid="youralerts")
elif uid == -1 or isGuestUser(uid):
return redirect_to_url(req, "%s/youraccount/login%s" % (
CFG_SITE_SECURE_URL,
make_canonical_urlargd({
'referer' : "%s/youralerts/display%s" % (
CFG_SITE_URL,
make_canonical_urlargd(argd, {})),
"ln" : argd['ln']}, {})))
user_info = collect_user_info(req)
if not user_info['precached_usealerts']:
return page_not_authorized(req, "../", \
text = _("You are not authorized to use alerts."))
if argd['p'] == 'y':
_title = _("Popular Searches")
else:
_title = _("Your Searches")
# register event in webstat
if user_info['email']:
user_str = "%s (%d)" % (user_info['email'], user_info['uid'])
else:
user_str = ""
try:
register_customevent("alerts", ["display", "", user_str])
except:
register_exception(suffix="Do the webstat tables exists? Try with 'webstatadmin --load-config'")
return page(title=_title,
body=webalert.perform_display(argd['p'], uid, ln=argd['ln']),
navtrail= """<a class="navtrail" href="%(sitesecureurl)s/youraccount/display?ln=%(ln)s">%(account)s</a>""" % {
'sitesecureurl' : CFG_SITE_SECURE_URL,
'ln': argd['ln'],
'account' : _("Your Account"),
},
description=_("%s Personalize, Display searches") % CFG_SITE_NAME_INTL.get(argd['ln'], CFG_SITE_NAME),
keywords=_("%s, personalize") % CFG_SITE_NAME_INTL.get(argd['ln'], CFG_SITE_NAME),
uid=uid,
language=argd['ln'],
req=req,
lastupdated=__lastupdated__,
navmenuid='youralerts',
secure_page_p=1)
示例3: index
def index(self, req, form):
"""Index page."""
argd = wash_urlargd(form, {'page': (int, 1),
'format': (str, "rc"),
'order_by': (str, "lcf"),
'per_page': (str, "all"),
})
# TODO: support also "reviews", by adding new option to show/hide them if needed
uid = getUid(req)
# load the right language
_ = gettext_set_language(argd['ln'])
# Is site ready to accept comments?
if not CFG_WEBCOMMENT_ALLOW_COMMENTS or CFG_ACCESS_CONTROL_LEVEL_SITE >= 1:
return page_not_authorized(req, "%s/yourcomments" % \
(CFG_SITE_SECURE_URL,),
text="Comments are currently disabled on this site",
navmenuid="yourcomments")
elif uid == -1 or isGuestUser(uid):
return redirect_to_url(req, "%s/youraccount/login%s" % (
CFG_SITE_SECURE_URL,
make_canonical_urlargd({
'referer' : "%s/yourcomments%s" % (
CFG_SITE_SECURE_URL,
make_canonical_urlargd(argd, {})),
"ln" : argd['ln']}, {})))
user_info = collect_user_info(req)
if not user_info['precached_sendcomments']:
# Maybe we should still authorize if user submitted
# comments in the past?
return page_not_authorized(req, "../", \
text = _("You are not authorized to use comments."))
return page(title=_("Your Comments"),
body=perform_display_your_comments(user_info,
page_number=argd['page'],
selected_order_by_option=argd['order_by'],
selected_display_number_option=argd['per_page'],
selected_display_format_option=argd['format'],
ln=argd['ln']),
navtrail= """<a class="navtrail" href="%(sitesecureurl)s/youraccount/display?ln=%(ln)s">%(account)s</a>""" % {
'sitesecureurl' : CFG_SITE_SECURE_URL,
'ln': argd['ln'],
'account' : _("Your Account"),
},
description=_("%s View your previously submitted comments") % CFG_SITE_NAME_INTL.get(argd['ln'], CFG_SITE_NAME),
keywords=_("%s, personalize") % CFG_SITE_NAME_INTL.get(argd['ln'], CFG_SITE_NAME),
uid=uid,
language=argd['ln'],
req=req,
lastupdated=__lastupdated__,
navmenuid='youralerts',
secure_page_p=1)
示例4: list
def list(self, req, form):
argd = wash_urlargd(form, {})
uid = getUid(req)
if CFG_ACCESS_CONTROL_LEVEL_SITE >= 1:
return page_not_authorized(req, "%s/youralerts/list" % (CFG_SITE_SECURE_URL,), navmenuid="youralerts")
elif uid == -1 or isGuestUser(uid):
return redirect_to_url(
req,
"%s/youraccount/login%s"
% (
CFG_SITE_SECURE_URL,
make_canonical_urlargd(
{
"referer": "%s/youralerts/list%s" % (CFG_SITE_SECURE_URL, make_canonical_urlargd(argd, {})),
"ln": argd["ln"],
},
{},
),
),
)
# load the right language
_ = gettext_set_language(argd["ln"])
user_info = collect_user_info(req)
if not user_info["precached_usealerts"]:
return page_not_authorized(req, "../", text=_("You are not authorized to use alerts."))
# register event in webstat
if user_info["email"]:
user_str = "%s (%d)" % (user_info["email"], user_info["uid"])
else:
user_str = ""
try:
register_customevent("alerts", ["list", "", user_str])
except:
register_exception(suffix="Do the webstat tables exists? Try with 'webstatadmin --load-config'")
return page(
title=_("Your Alerts"),
body=webalert.perform_list_alerts(uid, ln=argd["ln"]),
navtrail="""<a class="navtrail" href="%(sitesecureurl)s/youraccount/display?ln=%(ln)s">%(account)s</a>"""
% {"sitesecureurl": CFG_SITE_SECURE_URL, "ln": argd["ln"], "account": _("Your Account")},
description=_("%s Personalize, Display alerts") % CFG_SITE_NAME_INTL.get(argd["ln"], CFG_SITE_NAME),
keywords=_("%s, personalize") % CFG_SITE_NAME_INTL.get(argd["ln"], CFG_SITE_NAME),
uid=uid,
language=argd["ln"],
req=req,
lastupdated=__lastupdated__,
navmenuid="youralerts",
)
示例5: modify
def modify(self, req, form):
argd = wash_urlargd(form, {'idq': (int, None),
'old_idb': (int, None),
'name': (str, ""),
'freq': (str, "week"),
'notif': (str, "y"),
'idb': (int, 0),
'error_msg': (str, ""),
})
uid = getUid(req)
if CFG_ACCESS_CONTROL_LEVEL_SITE >= 1:
return page_not_authorized(req, "%s/youralerts/modify" % \
(CFG_SITE_URL,),
navmenuid="youralerts")
elif uid == -1 or isGuestUser(uid):
return redirect_to_url(req, "%s/youraccount/login%s" % (
CFG_SITE_SECURE_URL,
make_canonical_urlargd({
'referer' : "%s/youralerts/modify%s" % (
CFG_SITE_URL,
make_canonical_urlargd(argd, {})),
"ln" : argd['ln']}, {})))
# load the right language
_ = gettext_set_language(argd['ln'])
user_info = collect_user_info(req)
if not user_info['precached_usealerts']:
return page_not_authorized(req, "../", \
text = _("You are not authorized to use alerts."))
try:
html = webalert.perform_input_alert("update", argd['idq'], argd['name'], argd['freq'],
argd['notif'], argd['idb'], uid, argd['old_idb'], ln=argd['ln'])
except webalert.AlertError, msg:
return page(title=_("Error"),
body=webalert_templates.tmpl_errorMsg(ln=argd['ln'], error_msg=msg),
navtrail= """<a class="navtrail" href="%(sitesecureurl)s/youraccount/display?ln=%(ln)s">%(account)s</a>""" % {
'sitesecureurl' : CFG_SITE_SECURE_URL,
'ln': argd['ln'],
'account' : _("Your Account"),
},
description=_("%s Personalize, Set a new alert") % CFG_SITE_NAME_INTL.get(argd['ln'], CFG_SITE_NAME),
keywords=_("%s, personalize") % CFG_SITE_NAME_INTL.get(argd['ln'], CFG_SITE_NAME),
uid=uid,
language=argd['ln'],
req=req,
lastupdated=__lastupdated__,
navmenuid='youralerts')
示例6: tmpl_navtrailbox_body
def tmpl_navtrailbox_body(self, ln, title, previous_links,
separator, prolog, epilog):
"""Create navigation trail box body
Parameters:
- 'ln' *string* - The language to display
- 'title' *string* - page title;
- 'previous_links' *string* - the trail content from site title until current page (both ends exclusive)
- 'prolog' *string* - HTML code to prefix the navtrail item with
- 'epilog' *string* - HTML code to suffix the navtrail item with
- 'separator' *string* - HTML code that separates two navtrail items
Output:
- text containing the navtrail
Note: returns empty string for Home page. (guessed by title).
"""
# load the right message language
_ = gettext_set_language(ln)
out = ""
if title == CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME):
# return empty string for the Home page
return out
else:
out += create_html_link(CFG_SITE_URL, {'ln': ln},
_("Home"), {'class': 'navtrail'})
if previous_links:
if out:
out += separator
out += previous_links
if title:
if out:
out += separator
if title == CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME): # hide site name, print Home instead
out += cgi.escape(_("Home"))
else:
out += cgi.escape(title)
return cgi.escape(prolog) + out + cgi.escape(epilog)
示例7: format_element
def format_element(bfo, var=''):
'''
Print several server specific variables.
@param var: the name of the desired variable. Can be one of: CFG_SITE_NAME, CFG_SITE_NAME_INTL, CFG_SITE_LANG, CFG_VERSION, CFG_SITE_ADMIN_EMAIL, CFG_SITE_SUPPORT_EMAIL, CFG_SITE_URL, searchurl, recurl
CFG_SITE_NAME: the name of the server
CFG_SITE_NAME_INTL: internationalized name
CFG_SITE_LANG: the default language of the server
CFG_VERSION: the software version
CFG_SITE_ADMIN_EMAIL: the admin email
CFG_SITE_SUPPORT_EMAIL: the support email
CFG_SITE_URL: the base url for the server
searchurl: the search url for the server
recurl: the base url for the record
'''
recID = bfo.recID
if var == '':
out = ''
elif var in ['name', 'CFG_SITE_NAME']:
out = CFG_SITE_NAME
elif var in ['i18n_name', 'CFG_SITE_NAME_INTL']:
out = CFG_SITE_NAME_INTL.get(bfo.lang, CFG_SITE_NAME)
elif var in ['lang', 'CFG_SITE_LANG']:
out = CFG_SITE_LANG
elif var == 'CFG_VERSION':
out = 'Invenio v' + str(CFG_VERSION)
elif var in ['email', 'admin_email', 'CFG_SITE_ADMIN_EMAIL']:
out = CFG_SITE_ADMIN_EMAIL
elif var in ['support_email', 'CFG_SITE_SUPPORT_EMAIL']:
out = CFG_SITE_SUPPORT_EMAIL
elif var in ['CFG_SITE_RECORD']:
out = CFG_SITE_RECORD
elif var in ['weburl', 'CFG_SITE_URL']:
out = CFG_SITE_URL
if not out.endswith('/'):
out += '/'
elif var in ['CFG_BASE_URL']:
out = CFG_BASE_URL
if not out.endswith('/'):
out += '/'
elif var == 'searchurl':
out = CFG_BASE_URL + '/search'
if not out.endswith('/'):
out += '/'
elif var == 'absolutesearchurl':
out = CFG_SITE_URL + '/search'
if not out.endswith('/'):
out += '/'
elif var == 'recurl':
out = CFG_BASE_URL
if not out.endswith('/'):
out += '/'
out += CFG_SITE_RECORD + '/' + str(recID)
elif var == 'absoluterecurl':
out = CFG_SITE_URL
if not out.endswith('/'):
out += '/'
out += CFG_SITE_RECORD + '/' + str(recID)
else:
out = 'Unknown variable: %s' % (var)
return out
示例8: reset_password
def reset_password(email, ln=None):
"""Reset user password."""
from datetime import timedelta
from invenio.config import CFG_SITE_SUPPORT_EMAIL, CFG_SITE_NAME, \
CFG_SITE_NAME_INTL, CFG_WEBSESSION_RESET_PASSWORD_EXPIRE_IN_DAYS
# create the reset key
if ln is None:
ln = g.ln
from invenio.modules.access.mailcookie import mail_cookie_create_pw_reset
reset_key = mail_cookie_create_pw_reset(email, cookie_timeout=timedelta(
days=CFG_WEBSESSION_RESET_PASSWORD_EXPIRE_IN_DAYS))
if reset_key is None:
return False # reset key could not be created
# load the email template
import invenio.legacy.template
websession_templates = invenio.legacy.template.load('websession')
# finally send the email
from invenio.ext.email import send_email
from invenio.base.i18n import _
if not send_email(CFG_SITE_SUPPORT_EMAIL, email, "%s %s"
% (_("Password reset request for"),
CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME)),
websession_templates.
tmpl_account_reset_password_email_body(
email, reset_key, request.remote_addr, ln)):
return False # mail could not be sent
return True # password reset email send successfully
示例9: edit
def edit(self, req, form):
args = wash_urlargd(form, {"verbose" : (int, 0)})
uid = webuser.getUid(req)
# load the right message language
_ = gettext_set_language(args['ln'])
if uid == -1 or CFG_ACCESS_CONTROL_LEVEL_SITE >= 1:
return webuser.page_not_authorized(req, "../youraccount/edit",
navmenuid='youraccount')
if webuser.isGuestUser(uid):
return webuser.page_not_authorized(req, "../youraccount/edit",
text=_("This functionality is forbidden to guest users."),
navmenuid='youraccount')
body = ''
user_info = webuser.collect_user_info(req)
if args['verbose'] == 9:
keys = user_info.keys()
keys.sort()
for key in keys:
body += "<b>%s</b>:%s<br />" % (key, user_info[key])
# set CSRF token:
csrf_token, dummy_csrf_token_time = webuser.regenerate_csrf_token_if_needed(req)
#check if the user should see bibcatalog user name / passwd in the settings
can_config_bibcatalog = (acc_authorize_action(user_info, 'runbibedit')[0] == 0)
can_config_profiling = (acc_authorize_action(user_info, 'profiling')[0] == 0)
return page(title= _("Your Settings"),
body=body+webaccount.perform_set(webuser.get_email(uid),
args['ln'],
can_config_bibcatalog,
can_config_profiling,
verbose=args['verbose'],
csrf_token=csrf_token),
navtrail="""<a class="navtrail" href="%s/youraccount/display?ln=%s">""" % (CFG_SITE_SECURE_URL, args['ln']) + _("Your Account") + """</a>""",
description=_("%(x_name)s Personalize, Your Settings", x_name=CFG_SITE_NAME_INTL.get(args['ln'], CFG_SITE_NAME)),
keywords=_("%(x_name)s, personalize", x_name=CFG_SITE_NAME_INTL.get(args['ln'], CFG_SITE_NAME)),
uid=uid,
req=req,
secure_page_p = 1,
language=args['ln'],
lastupdated='',
navmenuid='youraccount')
示例10: delete
def delete(self, req, form):
args = wash_urlargd(form, {})
uid = webuser.getUid(req)
# load the right message language
_ = gettext_set_language(args['ln'])
if uid == -1 or CFG_ACCESS_CONTROL_LEVEL_SITE >= 1:
return webuser.page_not_authorized(req, "../youraccount/delete",
navmenuid='youraccount')
return page(title=_("Delete Account"),
body=webaccount.perform_delete(args['ln']),
navtrail="""<a class="navtrail" href="%s/youraccount/display?ln=%s">""" % (CFG_SITE_SECURE_URL, args['ln']) + _("Your Account") + """</a>""",
description="%s Personalize, Main page" % CFG_SITE_NAME_INTL.get(args['ln'], CFG_SITE_NAME),
keywords=_("%(x_name)s, personalize", x_name=CFG_SITE_NAME_INTL.get(args['ln'], CFG_SITE_NAME)),
uid=uid,
req=req,
secure_page_p = 1,
language=args['ln'],
lastupdated='',
navmenuid='youraccount')
示例11: warning_page
def warning_page(title, req, ln=CFG_SITE_LANG):
# load the right message language
_ = gettext_set_language(ln)
site_name = CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME)
return page(title = _("Warning"),
body = title,
description="%s - Internal Error" % site_name,
keywords="%s, Internal Error" % site_name,
uid = getUid(req),
language=ln,
req=req)
示例12: error_page
def error_page(title, req, ln=CFG_SITE_LANG):
# load the right message language
_ = gettext_set_language(ln)
site_name = CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME)
return page(title = _("Error"),
body = create_error_box(req, title=str(title), verbose=0, ln=ln),
description="%s - Internal Error" % site_name,
keywords="%s, Internal Error" % site_name,
uid = getUid(req),
language=ln,
req=req)
示例13: tmpl_navtrailbox_body
def tmpl_navtrailbox_body(self, ln, title, previous_links, separator,
prolog, epilog):
"""Bootstrap friendly-Create navigation trail box body
Parameters:
- 'ln' *string* - The language to display
- 'title' *string* - page title;
- 'previous_links' *string* - the trail content from site title until current page (both ends exclusive)
- 'prolog' *string* - HTML code to prefix the navtrail item with
- 'epilog' *string* - HTML code to suffix the navtrail item with
- 'separator' *string* - HTML code that separates two navtrail items
Output:
- text containing the navtrail
Note: returns empty string for Home page. (guessed by title).
"""
# load the right message language
_ = gettext_set_language(ln)
if title == CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME):
return ""
# Breadcrumbs
# breadcrumb objects should provide properties 'text' and 'url'
# First element
breadcrumbs = [dict(text=_("Home"), url=CFG_SITE_URL), ]
# Decode previous elements
if previous_links:
soup = BeautifulSoup(previous_links)
for link in soup.find_all('a'):
breadcrumbs.append(dict(
text=unicode(' '.join(link.contents)),
url=link.get('href')))
# Add head
if title:
breadcrumbs.append(dict(text=title, url='#'))
return render_template_to_string("breadcrumbs.html",
breadcrumbs=breadcrumbs).encode('utf8')
示例14: warningMsg
def warningMsg(title, req, c=None, ln=CFG_SITE_LANG):
# load the right message language
_ = gettext_set_language(ln)
if c is None:
c = CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME)
return page(title = _("Warning"),
body = title,
description="%s - Internal Error" % c,
keywords="%s, Internal Error" % c,
uid = getUid(req),
language=ln,
req=req,
navmenuid='submit')
示例15: format_element
def format_element(bfo):
"""
Display administration links for this articles when user is an
editor of the journal
"""
out = ''
if bfo.user_info['uri'].startswith('/journal'):
# Print editing links
args = parse_url_string(bfo.user_info['uri'])
journal_name = args["journal_name"]
editor = False
if acc_authorize_action(bfo.user_info['uid'], 'cfgwebjournal',
name="%s" % journal_name)[0] == 0:
editor = True
issue_number = args["issue"]
if editor:
recid = bfo.control_field('001')
(doctype, identifier_element, identifier_field) = \
get_journal_submission_params(journal_name)
if identifier_field.startswith('00'):
identifier = bfo.control_field(identifier_field)
else:
identifier = bfo.field(identifier_field)
out += '''
<div style="float:right;margin-left:5px;font-weight:700;">
<p>
<a href="%(CFG_SITE_URL)s/submit/direct?%(identifier_element)s=%(identifier)s&sub=MBI%(doctype)s" target="_blank"> >> edit article</a>
</p>
<p>
<a href="%(CFG_SITE_URL)s/%(CFG_SITE_RECORD)s/%(recid)s" target="_blank"> >> record in %(CFG_SITE_NAME_INTL)s</a>
</p>
<p>
<a href="%(CFG_SITE_URL)s/admin/webjournal/webjournaladmin.py/regenerate?journal_name=%(journal_name)s&issue=%(issue_number)s"> >> publish changes</a>
</p>
</div>''' % {'CFG_SITE_URL': CFG_SITE_URL,
'CFG_SITE_RECORD': CFG_SITE_RECORD,
'identifier': identifier,
'recid': recid,
'journal_name': journal_name,
'issue_number': issue_number,
'doctype': doctype,
'identifier_element': identifier_element,
'CFG_SITE_NAME_INTL': CFG_SITE_NAME_INTL.get(bfo.lang,
CFG_SITE_NAME)}
return out