allow navbar without define_tables, thanks Anthony
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.0.6 (2012-09-02 12:26:12) stable
|
Version 2.0.6 (2012-09-02 14:52:46) stable
|
||||||
|
|||||||
+4
-24
@@ -91,7 +91,8 @@ from validators import CRYPT
|
|||||||
from cache import Cache
|
from cache import Cache
|
||||||
from html import URL, xmlescape
|
from html import URL, xmlescape
|
||||||
from utils import is_valid_ip_address
|
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
|
import newcron
|
||||||
|
|
||||||
__all__ = ['wsgibase', 'save_password', 'appfactory', 'HttpServer']
|
__all__ = ['wsgibase', 'save_password', 'appfactory', 'HttpServer']
|
||||||
@@ -382,26 +383,7 @@ def wsgibase(environ, responder):
|
|||||||
# serve file if static
|
# serve file if static
|
||||||
# ##################################################
|
# ##################################################
|
||||||
|
|
||||||
eget = environ.get
|
fixup_missing_path_info(environ)
|
||||||
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')
|
|
||||||
|
|
||||||
|
|
||||||
(static_file, environ) = url_in(request, environ)
|
(static_file, environ) = url_in(request, environ)
|
||||||
|
|
||||||
if static_file:
|
if static_file:
|
||||||
@@ -438,6 +420,7 @@ def wsgibase(environ, responder):
|
|||||||
is_https = env.wsgi_url_scheme \
|
is_https = env.wsgi_url_scheme \
|
||||||
in ['https', 'HTTPS'] or env.https=='on')
|
in ['https', 'HTTPS'] or env.https=='on')
|
||||||
request.uuid = request.compute_uuid() # requires client
|
request.uuid = request.compute_uuid() # requires client
|
||||||
|
request.url = environ['PATH_INFO']
|
||||||
|
|
||||||
# ##################################################
|
# ##################################################
|
||||||
# access the requested application
|
# access the requested application
|
||||||
@@ -460,9 +443,6 @@ def wsgibase(environ, responder):
|
|||||||
elif not request.is_local and \
|
elif not request.is_local and \
|
||||||
exists(pjoin(request.folder,'DISABLED')):
|
exists(pjoin(request.folder,'DISABLED')):
|
||||||
raise HTTP(503, "<html><body><h1>Temporarily down for maintenance</h1></body></html>")
|
raise HTTP(503, "<html><body><h1>Temporarily down for maintenance</h1></body></html>")
|
||||||
request.url = URL(r=request,
|
|
||||||
args=request.args,
|
|
||||||
extension=request.raw_extension)
|
|
||||||
|
|
||||||
# ##################################################
|
# ##################################################
|
||||||
# build missing folders
|
# build missing folders
|
||||||
|
|||||||
@@ -135,6 +135,27 @@ ROUTER_BASE_KEYS = set(
|
|||||||
# filter_err: helper for doctest & unittest
|
# filter_err: helper for doctest & unittest
|
||||||
# regex_filter_out: doctest
|
# 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):
|
def url_in(request, environ):
|
||||||
"parse and rewrite incoming URL"
|
"parse and rewrite incoming URL"
|
||||||
if routers:
|
if routers:
|
||||||
|
|||||||
+14
-11
@@ -839,6 +839,7 @@ class Auth(object):
|
|||||||
table_event = None,
|
table_event = None,
|
||||||
table_cas = None,
|
table_cas = None,
|
||||||
showid = False,
|
showid = False,
|
||||||
|
use_username = False,
|
||||||
login_email_validate = True,
|
login_email_validate = True,
|
||||||
login_userfield = None,
|
login_userfield = None,
|
||||||
logout_onlogout = None,
|
logout_onlogout = None,
|
||||||
@@ -1060,7 +1061,6 @@ class Auth(object):
|
|||||||
request = current.request
|
request = current.request
|
||||||
session = current.session
|
session = current.session
|
||||||
auth = session.auth
|
auth = session.auth
|
||||||
self.use_username = None # None means postpone detection
|
|
||||||
self.user_groups = auth and auth.user_groups or {}
|
self.user_groups = auth and auth.user_groups or {}
|
||||||
if auth and auth.last_visit and auth.last_visit + \
|
if auth and auth.last_visit and auth.last_visit + \
|
||||||
datetime.timedelta(days=0, seconds=auth.expiration) > request.now:
|
datetime.timedelta(days=0, seconds=auth.expiration) > request.now:
|
||||||
@@ -1251,21 +1251,21 @@ class Auth(object):
|
|||||||
else:
|
else:
|
||||||
login = A(T('Login'), _href=href('login'))
|
login = A(T('Login'), _href=href('login'))
|
||||||
register = A(T('Register'), _href=href('register'))
|
register = A(T('Register'), _href=href('register'))
|
||||||
retrieve_username = A(T('Forgot username?'), _href=href('retrieve_username'))
|
retrieve_username = A(
|
||||||
lost_password = A(T('Lost password?'), _href=href('request_reset_password'))
|
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')
|
bar = SPAN(s1, login, s3, _class='auth_navbar')
|
||||||
|
|
||||||
if not 'register' in self.settings.actions_disabled:
|
if not 'register' in self.settings.actions_disabled:
|
||||||
bar.insert(-1, s2)
|
bar.insert(-1, s2)
|
||||||
bar.insert(-1, register)
|
bar.insert(-1, register)
|
||||||
if self.use_username is None:
|
if self.settings.use_username and not 'retrieve_username' \
|
||||||
# should always be false if auth.define_tables() is called
|
in self.settings.actions_disabled:
|
||||||
self.use_username = 'username' in self.table_user().fields
|
|
||||||
if self.use_username and \
|
|
||||||
not 'retrieve_username' in self.settings.actions_disabled:
|
|
||||||
bar.insert(-1, s2)
|
bar.insert(-1, s2)
|
||||||
bar.insert(-1, retrieve_username)
|
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, s2)
|
||||||
bar.insert(-1, lost_password)
|
bar.insert(-1, lost_password)
|
||||||
return bar
|
return bar
|
||||||
@@ -1357,7 +1357,7 @@ class Auth(object):
|
|||||||
writable=False,readable=False,
|
writable=False,readable=False,
|
||||||
label=T('Modified By')))
|
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):
|
migrate=True, fake_migrate=False):
|
||||||
"""
|
"""
|
||||||
to be called unless tables are defined manually
|
to be called unless tables are defined manually
|
||||||
@@ -1375,7 +1375,10 @@ class Auth(object):
|
|||||||
|
|
||||||
db = self.db
|
db = self.db
|
||||||
settings = self.settings
|
settings = self.settings
|
||||||
self.use_username = username
|
if username is None:
|
||||||
|
username = settings.use_username
|
||||||
|
else:
|
||||||
|
settings.use_username = username
|
||||||
if not self.signature:
|
if not self.signature:
|
||||||
self.define_signature()
|
self.define_signature()
|
||||||
if signature==True:
|
if signature==True:
|
||||||
|
|||||||
Reference in New Issue
Block a user