Skip to content
Myr

Added proper subdomain support

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 55040d3 · Browse files · 4 files+38 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+38 added−2 removed

  • tests:+21 added−0 removed
  • other:+17 added−2 removed

4 files+38 added−2 removed

modified:docs/config.rst+9 added
57 unmodified lines
58``SESSION_COOKIE_NAME`` the name of the session cookie59``PERMANENT_SESSION_LIFETIME`` the lifetime of a permanent session as60 :class:`datetime.timedelta` object.61``USE_X_SENDFILE`` enable/disable x-sendfile62``LOGGER_NAME`` the name of the logger63``SERVER_NAME`` the name of the server. Required for64 subdomain support (eg: ``'localhost'``)65=============================== =========================================6667.. versionadded:: 0.468 ``LOGGER_NAME``6970.. versionadded:: 0.571 ``SERVER_NAME``7273Configuring from Files74----------------------7576Configuration becomes more useful if you can configure from a file, and
58 unmodified lines
modified:tests/flask_tests.py+21 added
834 unmodified lines
835 finally:836 os.environ = env837838839class SubdomainTestCase(unittest.TestCase):840841 def test_basic_support(self):842 app = flask.Flask(__name__)843 app.config['SERVER_NAME'] = 'localhost'844 @app.route('/')845 def normal_index():846 return 'normal index'847 @app.route('/', subdomain='test')848 def test_index():849 return 'test index'850851 c = app.test_client()852 rv = c.get('/', 'http://localhost/')853 assert rv.data == 'normal index'854855 rv = c.get('/', 'http://test.localhost/')856 assert rv.data == 'test index'857858859def suite():860 from minitwit_tests import MiniTwitTestCase861 from flaskr_tests import FlaskrTestCase862 suite = unittest.TestSuite()
3 unmodified lines
866 suite.addTest(unittest.makeSuite(ModuleTestCase))867 suite.addTest(unittest.makeSuite(SendfileTestCase))868 suite.addTest(unittest.makeSuite(LoggingTestCase))869 suite.addTest(unittest.makeSuite(ConfigTestCase))870 suite.addTest(unittest.makeSuite(SubdomainTestCase))871 if flask.json_available:872 suite.addTest(unittest.makeSuite(JSONTestCase))873 suite.addTest(unittest.makeSuite(MiniTwitTestCase))874 suite.addTest(unittest.makeSuite(FlaskrTestCase))
5 unmodified lines
modified:CHANGES+4 added
6 unmodified lines
7-----------89Codename to be decided, release date to be announced.1011- fixed a bug with subdomains that was caused by the inability to12 specify the server name. The server name can now be set with13 the `SERVER_NAME` config key.1415Version 0.416-----------1718Released on June 18th 2010, codename Rakia
65 unmodified lines
modified:flask.py+4 added-2 removed
139 unmodified lines
140 """141142 def __init__(self, app, environ):143 self.app = app144 self.url_adapter = app.url_map.bind_to_environ(environ)144 self.url_adapter = app.url_map.bind_to_environ(environ,145 server_name=app.config['SERVER_NAME'])146 self.request = app.request_class(environ)147 self.session = app.open_session(self.request)148 if self.session is None:149 self.session = _NullSession()
739 unmodified lines
889 'SECRET_KEY': None,890 'SESSION_COOKIE_NAME': 'session',891 'PERMANENT_SESSION_LIFETIME': timedelta(days=31),892 'USE_X_SENDFILE': False,892 'LOGGER_NAME': None893 'LOGGER_NAME': None,894 'SERVER_NAME': None895 })896897 def __init__(self, import_name):898 _PackageBoundObject.__init__(self, import_name)
623 unmodified lines