Ejemplo n.º 1
0
Archivo: mainweb.py Proyecto: sup6/pali
def commonPage(prefix, word, reqHandlerName, urlLocale=None):
  if type(prefix) is not unicode:
    prefix = prefix.decode('utf-8')

  if word:
    if type(word) is not unicode:
      word = word.decode('utf-8')

  if not isValidPrefixAndWord(prefix, word):
    raise web.notfound()

  template_values = commonTemplateValues(
      urlLocale, reqHandlerName, prefix, word)

  if reqHandlerName == 'WordPage':
    pageHtml = getWordHtml(prefix, word)
  elif reqHandlerName == 'PrefixPage':
    pageHtml = getPrefixHtml(prefix)
  else:
    raise Exception('invalid reqHandlerName: %s' % reqHandlerName)

  if pageHtml is None: raise web.notfound()
  template_values['pageHtml'] = pageHtml
  template = jinja_environment.get_template('index.html')
  return template.render(template_values)
Ejemplo n.º 2
0
def commonPage(prefix, word, reqHandlerName, urlLocale=None):
  if web.ctx.host.split(':')[0] == "palidictionary.appspot.com":
    # redirect to new domain
    url = "http://dictionary.online-dhamma.net" + \
          urllib.quote(web.ctx.path.encode('utf-8')) + \
          web.ctx.query
    raise web.redirect(url)

  if type(prefix) is not unicode:
    prefix = prefix.decode('utf-8')

  if word:
    if type(word) is not unicode:
      word = word.decode('utf-8')

  if not isValidPrefixAndWord(prefix, word):
    raise web.notfound()

  template_values = commonTemplateValues(
      urlLocale, reqHandlerName, prefix, word)

  if reqHandlerName == 'WordPage':
    pageHtml = getWordHtml(prefix, word)
  elif reqHandlerName == 'PrefixPage':
    pageHtml = getPrefixHtml(prefix)
  else:
    raise Exception('invalid reqHandlerName: %s' % reqHandlerName)

  if pageHtml is None: raise web.notfound()
  template_values['pageHtml'] = pageHtml
  template = jinja_environment.get_template('index.html')
  return template.render(template_values)
Ejemplo n.º 3
0
 def get(self, prefix, word, urlLocale=None):
   if not isValidPrefixAndWord(prefix, word):
     self.abort(404)
   template_values = getCommonTemplateValues(self, urlLocale, prefix, word)
   wordHtml = getWordHtml(prefix, word)
   if wordHtml is None:
     self.abort(404)
   template_values['pageHtml'] = wordHtml
   template = jinja_environment.get_template('index.html')
   self.response.out.write(template.render(template_values))
Ejemplo n.º 4
0
 def get(self, prefix, word, urlLocale=None):
     if not isValidPrefixAndWord(prefix, word):
         self.abort(404)
     template_values = getCommonTemplateValues(self, urlLocale, prefix,
                                               word)
     wordHtml = getWordHtml(prefix, word)
     if wordHtml is None:
         self.abort(404)
     template_values['pageHtml'] = wordHtml
     template = jinja_environment.get_template('index.html')
     self.response.out.write(template.render(template_values))