diff --git a/VERSION b/VERSION index 1150a441..852bce5d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.0.6 (2012-09-02 12:26:12) stable +Version 2.0.6 (2012-09-02 14:52:46) stable diff --git a/gluon/main.py b/gluon/main.py index 94610f41..e60a38ac 100644 --- a/gluon/main.py +++ b/gluon/main.py @@ -91,7 +91,8 @@ from validators import CRYPT from cache import Cache from html import URL, xmlescape from utils import is_valid_ip_address -from rewrite import load, url_in, thread as rwthread, try_rewrite_on_error +from rewrite import load, url_in, thread as rwthread, \ + try_rewrite_on_error, fixup_missing_path_info import newcron __all__ = ['wsgibase', 'save_password', 'appfactory', 'HttpServer'] @@ -382,26 +383,7 @@ def wsgibase(environ, responder): # serve file if static # ################################################## - eget = environ.get - if not eget('PATH_INFO') and eget('REQUEST_URI'): - # for fcgi, get path_info and - # query_string from request_uri - items = environ['REQUEST_URI'].split('?') - environ['PATH_INFO'] = items[0] - if len(items) > 1: - environ['QUERY_STRING'] = items[1] - else: - environ['QUERY_STRING'] = '' - elif not eget('REQUEST_URI'): - if eget('QUERY_STRING'): - environ['REQUEST_URI'] = eget('PATH_INFO') + '?' + eget('QUERY_STRING') - else: - environ['REQUEST_URI'] = eget('PATH_INFO') - if not eget('HTTP_HOST'): - environ['HTTP_HOST'] = \ - eget('SERVER_NAME') + ':' + eget('SERVER_PORT') - - + fixup_missing_path_info(environ) (static_file, environ) = url_in(request, environ) if static_file: @@ -438,6 +420,7 @@ def wsgibase(environ, responder): is_https = env.wsgi_url_scheme \ in ['https', 'HTTPS'] or env.https=='on') request.uuid = request.compute_uuid() # requires client + request.url = environ['PATH_INFO'] # ################################################## # access the requested application @@ -460,9 +443,6 @@ def wsgibase(environ, responder): elif not request.is_local and \ exists(pjoin(request.folder,'DISABLED')): raise HTTP(503, "

Temporarily down for maintenance

") - request.url = URL(r=request, - args=request.args, - extension=request.raw_extension) # ################################################## # build missing folders diff --git a/gluon/rewrite.py b/gluon/rewrite.py index c7a1b211..411a3b15 100644 --- a/gluon/rewrite.py +++ b/gluon/rewrite.py @@ -135,6 +135,27 @@ ROUTER_BASE_KEYS = set( # filter_err: helper for doctest & unittest # regex_filter_out: doctest +def fixup_missing_path_info(environ): + eget = environ.get + path_info = eget('PATH_INFO') + request_uri = eget('REQUEST_URI') + if not path_info and request_uri: + # for fcgi, get path_info and + # query_string from request_uri + items = request_uri.split('?') + path_info = environ['PATH_INFO'] = items[0] + environ['QUERY_STRING'] = items[1] if len(items) > 1 else '' + elif not request_uri: + query_string = eget('QUERY_STRING') + if query_string: + environ['REQUEST_URI'] = '%s?%s' % (path_info,query_string) + else: + environ['REQUEST_URI'] = path_info + if not eget('HTTP_HOST'): + environ['HTTP_HOST'] = \ + '%s:%s' % (eget('SERVER_NAME'),eget('SERVER_PORT')) + + def url_in(request, environ): "parse and rewrite incoming URL" if routers: diff --git a/gluon/tools.py b/gluon/tools.py index ecbc37e2..1492fd62 100644 --- a/gluon/tools.py +++ b/gluon/tools.py @@ -839,6 +839,7 @@ class Auth(object): table_event = None, table_cas = None, showid = False, + use_username = False, login_email_validate = True, login_userfield = None, logout_onlogout = None, @@ -1060,7 +1061,6 @@ class Auth(object): request = current.request session = current.session auth = session.auth - self.use_username = None # None means postpone detection self.user_groups = auth and auth.user_groups or {} if auth and auth.last_visit and auth.last_visit + \ datetime.timedelta(days=0, seconds=auth.expiration) > request.now: @@ -1251,21 +1251,21 @@ class Auth(object): else: login = A(T('Login'), _href=href('login')) register = A(T('Register'), _href=href('register')) - retrieve_username = A(T('Forgot username?'), _href=href('retrieve_username')) - lost_password = A(T('Lost password?'), _href=href('request_reset_password')) + retrieve_username = A( + T('Forgot username?'), _href=href('retrieve_username')) + lost_password = A( + T('Lost password?'), _href=href('request_reset_password')) bar = SPAN(s1, login, s3, _class='auth_navbar') if not 'register' in self.settings.actions_disabled: bar.insert(-1, s2) bar.insert(-1, register) - if self.use_username is None: - # should always be false if auth.define_tables() is called - self.use_username = 'username' in self.table_user().fields - if self.use_username and \ - not 'retrieve_username' in self.settings.actions_disabled: + if self.settings.use_username and not 'retrieve_username' \ + in self.settings.actions_disabled: bar.insert(-1, s2) bar.insert(-1, retrieve_username) - if not 'request_reset_password' in self.settings.actions_disabled: + if not 'request_reset_password' \ + in self.settings.actions_disabled: bar.insert(-1, s2) bar.insert(-1, lost_password) return bar @@ -1357,7 +1357,7 @@ class Auth(object): writable=False,readable=False, label=T('Modified By'))) - def define_tables(self, username=False, signature=None, + def define_tables(self, username=None, signature=None, migrate=True, fake_migrate=False): """ to be called unless tables are defined manually @@ -1375,7 +1375,10 @@ class Auth(object): db = self.db settings = self.settings - self.use_username = username + if username is None: + username = settings.use_username + else: + settings.use_username = username if not self.signature: self.define_signature() if signature==True: