Parcourir la source

[wsgi] [minor] fixed request host name

version-14
Rushabh Mehta il y a 12 ans
Parent
révision
382ef961c4
7 fichiers modifiés avec 10 ajouts et 11 suppressions
  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 Voir le fichier

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


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


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


+ 1
- 1
webnotes/auth.py Voir le fichier

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


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




+ 0
- 1
webnotes/install_lib/setup_public_folder.py Voir le fichier

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




+ 1
- 1
webnotes/modules/patch_handler.py Voir le fichier

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


block_user(False) block_user(False)


+ 1
- 0
webnotes/utils/__init__.py Voir le fichier

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


+ 2
- 3
website/templates/pages/rss.py Voir le fichier

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


no_cache = True no_cache = True


def get_context(): def get_context():
"""generate rss feed""" """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("""\ blog_list = webnotes.conn.sql("""\
select page_name as name, published_on, modified, title, content from `tabBlog Post` select page_name as name, published_on, modified, title, content from `tabBlog Post`


+ 2
- 3
website/templates/pages/sitemap.py Voir le fichier

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


def get_context(): def get_context():
"""generate the sitemap XML""" """generate the sitemap XML"""
links = webnotes.webutils.get_website_sitemap().items() 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: for l in links:
l[1]["loc"] = urllib.basejoin(host, urllib.quote(l[1].get("page_name", l[1]["link_name"]))) l[1]["loc"] = urllib.basejoin(host, urllib.quote(l[1].get("page_name", l[1]["link_name"])))


Chargement…
Annuler
Enregistrer