Kaynağa Gözat

[wsgi] [minor] fixed request host name

version-14
Rushabh Mehta 12 yıl önce
ebeveyn
işleme
382ef961c4
7 değiştirilmiş dosya ile 10 ekleme ve 11 silme
  1. +3
    -2
      webnotes/app.py
  2. +1
    -1
      webnotes/auth.py
  3. +0
    -1
      webnotes/install_lib/setup_public_folder.py
  4. +1
    -1
      webnotes/modules/patch_handler.py
  5. +1
    -0
      webnotes/utils/__init__.py
  6. +2
    -3
      website/templates/pages/rss.py
  7. +2
    -3
      website/templates/pages/sitemap.py

+ 3
- 2
webnotes/app.py Dosyayı Görüntüle

@@ -1,6 +1,6 @@
import sys, os

sys.path.extend(["..", "../app", "../lib"])
sys.path.extend([".", "app", "lib"])

from werkzeug.wrappers import Request, Response
from werkzeug.local import LocalManager
@@ -17,8 +17,9 @@ local_manager = LocalManager([webnotes.local])
@Request.application
def application(request):
webnotes.local.request = request
webnotes.init()
webnotes.local.form_dict = webnotes._dict({ k:v[0] if isinstance(v, (list, tuple)) else v \
for k, v in (request.form or request.args).iteritems() })


+ 1
- 1
webnotes/auth.py Dosyayı Görüntüle

@@ -14,7 +14,7 @@ class HTTPRequest:
def __init__(self):

# Get Environment variables
self.domain = webnotes.get_request_header('HTTP_HOST')
self.domain = webnotes.request.host
if self.domain and self.domain.startswith('www.'):
self.domain = self.domain[4:]



+ 0
- 1
webnotes/install_lib/setup_public_folder.py Dosyayı Görüntüle

@@ -20,7 +20,6 @@ def make():
symlinks = [
["app", "../app/public"],
["lib", "../lib/public"],
["blank.html", "../lib/public/html/blank.html"],
["unsupported.html", "../lib/public/html/unsupported.html"]
]



+ 1
- 1
webnotes/modules/patch_handler.py Dosyayı Görüntüle

@@ -66,7 +66,7 @@ def execute_patch(patchmodule, method=None, methodargs=None):
tb = webnotes.getTraceback()
log(tb)
import os
if webnotes.get_request_header('HTTP_HOST'):
if webnotes.request:
add_to_patch_log(tb)

block_user(False)


+ 1
- 0
webnotes/utils/__init__.py Dosyayı Görüntüle

@@ -71,6 +71,7 @@ def get_request_site_address(full_address=False):
host_name = conf.host_name
else:
try:
host = webnotes.request.host
protocol = 'HTTPS' in webnotes.get_request_header('SERVER_PROTOCOL') and 'https://' or 'http://'
host_name = protocol + webnotes.get_request_header('HTTP_HOST')
except TypeError:


+ 2
- 3
website/templates/pages/rss.py Dosyayı Görüntüle

@@ -1,14 +1,13 @@
import webnotes
import os, urllib
from webnotes.utils import escape_html
from webnotes.utils import escape_html, get_request_site_address

no_cache = True

def get_context():
"""generate rss feed"""
host = ('https://' if webnotes.get_request_header('HTTPS') else 'http://') \
+ webnotes.get_request_header('HTTP_HOST', "localhost")
host = get_request_site_address()
blog_list = webnotes.conn.sql("""\
select page_name as name, published_on, modified, title, content from `tabBlog Post`


+ 2
- 3
website/templates/pages/sitemap.py Dosyayı Görüntüle

@@ -6,13 +6,12 @@ from __future__ import unicode_literals
import urllib
import webnotes
import webnotes.webutils
from webnotes.utils import get_request_site_address

def get_context():
"""generate the sitemap XML"""
links = webnotes.webutils.get_website_sitemap().items()

host = ('https://' if webnotes.get_request_header('HTTPS') else 'http://') \
+ webnotes.get_request_header('HTTP_HOST', "localhost")
host = get_request_site_address()
for l in links:
l[1]["loc"] = urllib.basejoin(host, urllib.quote(l[1].get("page_name", l[1]["link_name"])))


Yükleniyor…
İptal
Kaydet