Merge github.com:web2py/web2py
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.00.1 (2012-08-28 22:14:54) rc4
|
Version 2.00.1 (2012-08-29 07:27:23) rc4
|
||||||
|
|||||||
+704
-482
File diff suppressed because it is too large
Load Diff
+11
-11
@@ -425,14 +425,14 @@ def wsgibase(environ, responder):
|
|||||||
client = get_client(env)
|
client = get_client(env)
|
||||||
x_req_with = str(env.http_x_requested_with).lower()
|
x_req_with = str(env.http_x_requested_with).lower()
|
||||||
|
|
||||||
request.update(dict(
|
request.update(
|
||||||
client = client,
|
client = client,
|
||||||
folder = abspath('applications',app) + os.sep,
|
folder = abspath('applications',app) + os.sep,
|
||||||
ajax = x_req_with == 'xmlhttprequest',
|
ajax = x_req_with == 'xmlhttprequest',
|
||||||
cid = env.http_web2py_component_element,
|
cid = env.http_web2py_component_element,
|
||||||
is_local = env.remote_addr in local_hosts,
|
is_local = env.remote_addr in local_hosts,
|
||||||
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
|
||||||
|
|
||||||
# ##################################################
|
# ##################################################
|
||||||
@@ -561,15 +561,15 @@ def wsgibase(environ, responder):
|
|||||||
# ##################################################
|
# ##################################################
|
||||||
|
|
||||||
if request.cid:
|
if request.cid:
|
||||||
rheaders
|
rheaders = response.headers
|
||||||
if response.flash and \
|
if response.flash and \
|
||||||
not 'web2py-component-flash' in rheaders:
|
not 'web2py-component-flash' in rheaders:
|
||||||
rheaders['web2py-component-flash'] = \
|
rheaders['web2py-component-flash'] = \
|
||||||
urllib2.quote(xmlescape(response.flash)\
|
urllib2.quote(xmlescape(response.flash)\
|
||||||
.replace('\n',''))
|
.replace('\n',''))
|
||||||
if response.js and \
|
if response.js and \
|
||||||
not 'web2py-component-command' in readers:
|
not 'web2py-component-command' in rheaders:
|
||||||
readers['web2py-component-command'] = \
|
rheaders['web2py-component-command'] = \
|
||||||
response.js.replace('\n','')
|
response.js.replace('\n','')
|
||||||
rcookies = response.cookies
|
rcookies = response.cookies
|
||||||
if session._forget and \
|
if session._forget and \
|
||||||
|
|||||||
+1
-1
@@ -292,7 +292,7 @@ class MultipleOptionsWidget(OptionsWidget):
|
|||||||
be shown
|
be shown
|
||||||
"""
|
"""
|
||||||
|
|
||||||
attributes.update(dict(_size=size, _multiple=True))
|
attributes.update(_size=size, _multiple=True)
|
||||||
|
|
||||||
return OptionsWidget.widget(field, value, **attributes)
|
return OptionsWidget.widget(field, value, **attributes)
|
||||||
|
|
||||||
|
|||||||
+179
-178
@@ -800,139 +800,139 @@ def addrow(form, a, b, c, style, _id, position=-1):
|
|||||||
|
|
||||||
class Auth(object):
|
class Auth(object):
|
||||||
|
|
||||||
default_settings = {
|
default_settings = dict(
|
||||||
'hideerror': False,
|
hideerror = False,
|
||||||
'password_min_length': 4,
|
password_min_length = 4,
|
||||||
'cas_maps': None,
|
cas_maps = None,
|
||||||
'reset_password_requires_verification': False,
|
reset_password_requires_verification = False,
|
||||||
'registration_requires_verification': False,
|
registration_requires_verification = False,
|
||||||
'registration_requires_approval': False,
|
registration_requires_approval = False,
|
||||||
'login_after_registration': False,
|
login_after_registration = False,
|
||||||
'login_after_password_change': True,
|
login_after_password_change = True,
|
||||||
'alternate_requires_registration': False,
|
alternate_requires_registration = False,
|
||||||
'create_user_groups': "user_%(id)s",
|
create_user_groups = "user_%(id)s",
|
||||||
'everybody_group_id': None,
|
everybody_group_id = None,
|
||||||
'login_captcha': None,
|
login_captcha = None,
|
||||||
'register_captcha': None,
|
register_captcha = None,
|
||||||
'retrieve_username_captcha': None,
|
retrieve_username_captcha = None,
|
||||||
'retrieve_password_captcha': None,
|
retrieve_password_captcha = None,
|
||||||
'captcha': None,
|
captcha = None,
|
||||||
'expiration': 3600, # one hour
|
expiration = 3600, # one hour
|
||||||
'long_expiration': 3600*30*24, # one month
|
long_expiration = 3600*30*24, # one month
|
||||||
'remember_me_form': True,
|
remember_me_form = True,
|
||||||
'allow_basic_login': False,
|
allow_basic_login = False,
|
||||||
'allow_basic_login_only': False,
|
allow_basic_login_only = False,
|
||||||
'on_failed_authentication': lambda x: redirect(x),
|
on_failed_authentication = lambda x: redirect(x),
|
||||||
'formstyle': 'table3cols',
|
formstyle = "table3cols",
|
||||||
'label_separator': ': ',
|
label_separator = ": ",
|
||||||
'password_field': 'password',
|
password_field = 'password',
|
||||||
'table_user_name': 'auth_user',
|
table_user_name = 'auth_user',
|
||||||
'table_group_name': 'auth_group',
|
table_group_name = 'auth_group',
|
||||||
'table_membership_name': 'auth_membership',
|
table_membership_name = 'auth_membership',
|
||||||
'table_permission_name': 'auth_permission',
|
table_permission_name = 'auth_permission',
|
||||||
'table_event_name': 'auth_event',
|
table_event_name = 'auth_event',
|
||||||
'table_cas_name': 'auth_cas',
|
table_cas_name = 'auth_cas',
|
||||||
'table_user': None,
|
table_user = None,
|
||||||
'table_group': None,
|
table_group = None,
|
||||||
'table_membership': None,
|
table_membership = None,
|
||||||
'table_permission': None,
|
table_permission = None,
|
||||||
'table_event': None,
|
table_event = None,
|
||||||
'table_cas': None,
|
table_cas = None,
|
||||||
'showid': False,
|
showid = False,
|
||||||
'login_email_validate': True,
|
login_email_validate = True,
|
||||||
'login_userfield': None,
|
login_userfield = None,
|
||||||
'logout_onlogout': None,
|
logout_onlogout = None,
|
||||||
'register_fields': None,
|
register_fields = None,
|
||||||
'register_verify_password': True,
|
register_verify_password = True,
|
||||||
'profile_fields': None,
|
profile_fields = None,
|
||||||
'email_case_sensitive': True,
|
email_case_sensitive = True,
|
||||||
'username_case_sensitive': True,
|
username_case_sensitive = True,
|
||||||
}
|
)
|
||||||
# ## these are messages that can be customized
|
# ## these are messages that can be customized
|
||||||
default_messages = {
|
default_messages = dict(
|
||||||
'login_button': 'Login',
|
login_button = 'Login',
|
||||||
'register_button': 'Register',
|
register_button = 'Register',
|
||||||
'password_reset_button': 'Request reset password',
|
password_reset_button = 'Request reset password',
|
||||||
'password_change_button': 'Change password',
|
password_change_button = 'Change password',
|
||||||
'profile_save_button': 'Save profile',
|
profile_save_button = 'Save profile',
|
||||||
'submit_button': 'Submit',
|
submit_button = 'Submit',
|
||||||
'verify_password': 'Verify Password',
|
verify_password = 'Verify Password',
|
||||||
'delete_label': 'Check to delete',
|
delete_label = 'Check to delete',
|
||||||
'function_disabled': 'Function disabled',
|
function_disabled = 'Function disabled',
|
||||||
'access_denied': 'Insufficient privileges',
|
access_denied = 'Insufficient privileges',
|
||||||
'registration_verifying': 'Registration needs verification',
|
registration_verifying = 'Registration needs verification',
|
||||||
'registration_pending': 'Registration is pending approval',
|
registration_pending = 'Registration is pending approval',
|
||||||
'login_disabled': 'Login disabled by administrator',
|
login_disabled = 'Login disabled by administrator',
|
||||||
'logged_in': 'Logged in',
|
logged_in = 'Logged in',
|
||||||
'email_sent': 'Email sent',
|
email_sent = 'Email sent',
|
||||||
'unable_to_send_email': 'Unable to send email',
|
unable_to_send_email = 'Unable to send email',
|
||||||
'email_verified': 'Email verified',
|
email_verified = 'Email verified',
|
||||||
'logged_out': 'Logged out',
|
logged_out = 'Logged out',
|
||||||
'registration_successful': 'Registration successful',
|
registration_successful = 'Registration successful',
|
||||||
'invalid_email': 'Invalid email',
|
invalid_email = 'Invalid email',
|
||||||
'unable_send_email': 'Unable to send email',
|
unable_send_email = 'Unable to send email',
|
||||||
'invalid_login': 'Invalid login',
|
invalid_login = 'Invalid login',
|
||||||
'invalid_user': 'Invalid user',
|
invalid_user = 'Invalid user',
|
||||||
'invalid_password': 'Invalid password',
|
invalid_password = 'Invalid password',
|
||||||
'is_empty': "Cannot be empty",
|
is_empty = "Cannot be empty",
|
||||||
'mismatched_password': "Password fields don't match",
|
mismatched_password = "Password fields don't match",
|
||||||
'verify_email': 'Click on the link %(link)s to verify your email',
|
verify_email = 'Click on the link %(link)s to verify your email',
|
||||||
'verify_email_subject': 'Email verification',
|
verify_email_subject = 'Email verification',
|
||||||
'username_sent': 'Your username was emailed to you',
|
username_sent = 'Your username was emailed to you',
|
||||||
'new_password_sent': 'A new password was emailed to you',
|
new_password_sent = 'A new password was emailed to you',
|
||||||
'password_changed': 'Password changed',
|
password_changed = 'Password changed',
|
||||||
'retrieve_username': 'Your username is: %(username)s',
|
retrieve_username = 'Your username is: %(username)s',
|
||||||
'retrieve_username_subject': 'Username retrieve',
|
retrieve_username_subject = 'Username retrieve',
|
||||||
'retrieve_password': 'Your password is: %(password)s',
|
retrieve_password = 'Your password is: %(password)s',
|
||||||
'retrieve_password_subject': 'Password retrieve',
|
retrieve_password_subject = 'Password retrieve',
|
||||||
'reset_password': \
|
reset_password = \
|
||||||
'Click on the link %(link)s to reset your password',
|
'Click on the link %(link)s to reset your password',
|
||||||
'reset_password_subject': 'Password reset',
|
reset_password_subject = 'Password reset',
|
||||||
'invalid_reset_password': 'Invalid reset password',
|
invalid_reset_password = 'Invalid reset password',
|
||||||
'profile_updated': 'Profile updated',
|
profile_updated = 'Profile updated',
|
||||||
'new_password': 'New password',
|
new_password = 'New password',
|
||||||
'old_password': 'Old password',
|
old_password = 'Old password',
|
||||||
'group_description': 'Group uniquely assigned to user %(id)s',
|
group_description = 'Group uniquely assigned to user %(id)s',
|
||||||
'register_log': 'User %(id)s Registered',
|
register_log = 'User %(id)s Registered',
|
||||||
'login_log': 'User %(id)s Logged-in',
|
login_log = 'User %(id)s Logged-in',
|
||||||
'login_failed_log': None,
|
login_failed_log = None,
|
||||||
'logout_log': 'User %(id)s Logged-out',
|
logout_log = 'User %(id)s Logged-out',
|
||||||
'profile_log': 'User %(id)s Profile updated',
|
profile_log = 'User %(id)s Profile updated',
|
||||||
'verify_email_log': 'User %(id)s Verification email sent',
|
verify_email_log = 'User %(id)s Verification email sent',
|
||||||
'retrieve_username_log': 'User %(id)s Username retrieved',
|
retrieve_username_log = 'User %(id)s Username retrieved',
|
||||||
'retrieve_password_log': 'User %(id)s Password retrieved',
|
retrieve_password_log = 'User %(id)s Password retrieved',
|
||||||
'reset_password_log': 'User %(id)s Password reset',
|
reset_password_log = 'User %(id)s Password reset',
|
||||||
'change_password_log': 'User %(id)s Password changed',
|
change_password_log = 'User %(id)s Password changed',
|
||||||
'add_group_log': 'Group %(group_id)s created',
|
add_group_log = 'Group %(group_id)s created',
|
||||||
'del_group_log': 'Group %(group_id)s deleted',
|
del_group_log = 'Group %(group_id)s deleted',
|
||||||
'add_membership_log': None,
|
add_membership_log = None,
|
||||||
'del_membership_log': None,
|
del_membership_log = None,
|
||||||
'has_membership_log': None,
|
has_membership_log = None,
|
||||||
'add_permission_log': None,
|
add_permission_log = None,
|
||||||
'del_permission_log': None,
|
del_permission_log = None,
|
||||||
'has_permission_log': None,
|
has_permission_log = None,
|
||||||
'impersonate_log': 'User %(id)s is impersonating %(other_id)s',
|
impersonate_log = 'User %(id)s is impersonating %(other_id)s',
|
||||||
'label_first_name': 'First name',
|
label_first_name = 'First name',
|
||||||
'label_last_name': 'Last name',
|
label_last_name = 'Last name',
|
||||||
'label_username': 'Username',
|
label_username = 'Username',
|
||||||
'label_email': 'E-mail',
|
label_email = 'E-mail',
|
||||||
'label_password': 'Password',
|
label_password = 'Password',
|
||||||
'label_registration_key': 'Registration key',
|
label_registration_key = 'Registration key',
|
||||||
'label_reset_password_key': 'Reset Password key',
|
label_reset_password_key = 'Reset Password key',
|
||||||
'label_registration_id': 'Registration identifier',
|
label_registration_id = 'Registration identifier',
|
||||||
'label_role': 'Role',
|
label_role = 'Role',
|
||||||
'label_description': 'Description',
|
label_description = 'Description',
|
||||||
'label_user_id': 'User ID',
|
label_user_id = 'User ID',
|
||||||
'label_group_id': 'Group ID',
|
label_group_id = 'Group ID',
|
||||||
'label_name': 'Name',
|
label_name = 'Name',
|
||||||
'label_table_name': 'Object or table name',
|
label_table_name = 'Object or table name',
|
||||||
'label_record_id': 'Record ID',
|
label_record_id = 'Record ID',
|
||||||
'label_time_stamp': 'Timestamp',
|
label_time_stamp = 'Timestamp',
|
||||||
'label_client_ip': 'Client IP',
|
label_client_ip = 'Client IP',
|
||||||
'label_origin': 'Origin',
|
label_origin = 'Origin',
|
||||||
'label_remember_me': "Remember me (for 30 days)",
|
label_remember_me = "Remember me (for 30 days)",
|
||||||
'verify_password_comment': 'please input your password again',
|
verify_password_comment = 'please input your password again',
|
||||||
}
|
)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Class for authentication, authorization, role based access control.
|
Class for authentication, authorization, role based access control.
|
||||||
@@ -1081,51 +1081,51 @@ class Auth(object):
|
|||||||
|
|
||||||
settings = self.settings = Settings()
|
settings = self.settings = Settings()
|
||||||
settings.update(Auth.default_settings)
|
settings.update(Auth.default_settings)
|
||||||
settings.update({
|
settings.update(
|
||||||
'cas_domains': [request.env.http_host],
|
cas_domains = [request.env.http_host],
|
||||||
'cas_provider': cas_provider,
|
cas_provider = cas_provider,
|
||||||
'cas_actions': {'login':'login',
|
cas_actions = dict(login ='login',
|
||||||
'validate':'validate',
|
validate ='validate',
|
||||||
'servicevalidate':'serviceValidate',
|
servicevalidate ='serviceValidate',
|
||||||
'proxyvalidate':'proxyValidate',
|
proxyvalidate ='proxyValidate',
|
||||||
'logout':'logout'},
|
logout ='logout'),
|
||||||
'extra_fields': {},
|
extra_fields = {},
|
||||||
'actions_disabled': [],
|
actions_disabled = [],
|
||||||
'controller': controller,
|
controller = controller,
|
||||||
'function': function,
|
function = function,
|
||||||
'login_url': url_login,
|
login_url = url_login,
|
||||||
'logged_url': URL(controller, function, args='profile'),
|
logged_url = URL(controller, function, args='profile'),
|
||||||
'download_url': URL(controller,'download'),
|
download_url = URL(controller,'download'),
|
||||||
'mailer': (mailer==True) and Mail() or mailer,
|
mailer = (mailer==True) and Mail() or mailer,
|
||||||
'on_failed_authorization': \
|
on_failed_authorization = \
|
||||||
URL(controller,function, args='not_authorized'),
|
URL(controller,function, args='not_authorized'),
|
||||||
'login_next': url_index,
|
login_next = url_index,
|
||||||
'login_onvalidation': [],
|
login_onvalidation = [],
|
||||||
'login_onaccept': [],
|
login_onaccept = [],
|
||||||
'login_methods': [self],
|
login_methods = [self],
|
||||||
'login_form': self,
|
login_form = self,
|
||||||
'logout_next': url_index,
|
logout_next = url_index,
|
||||||
'logout_onlogout': None,
|
logout_onlogout = None,
|
||||||
'register_next': url_index,
|
register_next = url_index,
|
||||||
'register_onvalidation': [],
|
register_onvalidation = [],
|
||||||
'register_onaccept': [],
|
register_onaccept = [],
|
||||||
'verify_email_next': url_login,
|
verify_email_next = url_login,
|
||||||
'verify_email_onaccept': [],
|
verify_email_onaccept = [],
|
||||||
'profile_next': url_index,
|
profile_next = url_index,
|
||||||
'profile_onvalidation': [],
|
profile_onvalidation = [],
|
||||||
'profile_onaccept': [],
|
profile_onaccept = [],
|
||||||
'retrieve_username_next': url_index,
|
retrieve_username_next = url_index,
|
||||||
'retrieve_password_next': url_index,
|
retrieve_password_next = url_index,
|
||||||
'request_reset_password_next': url_login,
|
request_reset_password_next = url_login,
|
||||||
'reset_password_next': url_index,
|
reset_password_next = url_index,
|
||||||
'change_password_next': url_index,
|
change_password_next = url_index,
|
||||||
'change_password_onvalidation': [],
|
change_password_onvalidation = [],
|
||||||
'change_password_onaccept': [],
|
change_password_onaccept = [],
|
||||||
'retrieve_password_onvalidation': [],
|
retrieve_password_onvalidation = [],
|
||||||
'reset_password_onvalidation': [],
|
reset_password_onvalidation = [],
|
||||||
'reset_password_onaccept': [],
|
reset_password_onaccept = [],
|
||||||
'hmac_key': hmac_key,
|
hmac_key = hmac_key,
|
||||||
})
|
)
|
||||||
settings.lock_keys = True
|
settings.lock_keys = True
|
||||||
|
|
||||||
# ## these are messages that can be customized
|
# ## these are messages that can be customized
|
||||||
@@ -2344,8 +2344,9 @@ class Auth(object):
|
|||||||
redirect(self.url(args=request.args))
|
redirect(self.url(args=request.args))
|
||||||
password = self.random_password()
|
password = self.random_password()
|
||||||
passfield = self.settings.password_field
|
passfield = self.settings.password_field
|
||||||
d = {passfield: str(table_user[passfield].validate(password)[0]),
|
d = dict(
|
||||||
'registration_key': ''}
|
passfield = str(table_user[passfield].validate(password)[0]),
|
||||||
|
registration_key = '')
|
||||||
user.update_record(**d)
|
user.update_record(**d)
|
||||||
if self.settings.mailer and \
|
if self.settings.mailer and \
|
||||||
self.settings.mailer.send(to=form.vars.email,
|
self.settings.mailer.send(to=form.vars.email,
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import time
|
||||||
|
import sys
|
||||||
|
import urllib2
|
||||||
|
import urllib2
|
||||||
|
|
||||||
|
n = int(sys.argv[1])
|
||||||
|
url = sys.argv[2]
|
||||||
|
headers = {"Accept-Language" : "en" }
|
||||||
|
req = urllib2.Request(url, None, headers)
|
||||||
|
|
||||||
|
t0 = time.time()
|
||||||
|
for k in xrange(n):
|
||||||
|
data = urllib2.urlopen(req).read()
|
||||||
|
print (time.time()-t0)/n
|
||||||
|
if n==1: print data
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
|
paths = [sys.argv[1]]
|
||||||
|
paths1 = []
|
||||||
|
paths2 = []
|
||||||
|
while paths:
|
||||||
|
path = paths.pop()
|
||||||
|
for filename in os.listdir(path):
|
||||||
|
fullname = os.path.join(path,filename)
|
||||||
|
if os.path.isdir(fullname):
|
||||||
|
paths.append(fullname)
|
||||||
|
else:
|
||||||
|
extension = filename.split('.')[-1]
|
||||||
|
if extension.lower() in ('png','gif','jpg','jpeg','js','css'):
|
||||||
|
paths1.append((filename,fullname))
|
||||||
|
if extension.lower() in ('css','js','py','html'):
|
||||||
|
paths2.append(fullname)
|
||||||
|
for filename,fullname in paths1:
|
||||||
|
for otherfullname in paths2:
|
||||||
|
if open(otherfullname).read().find(filename)>=0:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
print fullname
|
||||||
|
# os.system('hg rm '+fullname)
|
||||||
|
# os.system('rm '+fullname)
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
|
paths = [sys.argv[1]]
|
||||||
|
paths1 = []
|
||||||
|
paths2 = []
|
||||||
|
while paths:
|
||||||
|
path = paths.pop()
|
||||||
|
for filename in os.listdir(path):
|
||||||
|
fullname = os.path.join(path,filename)
|
||||||
|
if os.path.isdir(fullname):
|
||||||
|
paths.append(fullname)
|
||||||
|
else:
|
||||||
|
extension = filename.split('.')[-1]
|
||||||
|
if extension.lower() in ('png','gif','jpg','jpeg','js','css'):
|
||||||
|
paths1.append((filename,fullname))
|
||||||
|
if extension.lower() in ('css','js','py','html'):
|
||||||
|
paths2.append(fullname)
|
||||||
|
for filename,fullname in paths1:
|
||||||
|
for otherfullname in paths2:
|
||||||
|
if open(otherfullname).read().find(filename)>=0:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
print fullname
|
||||||
|
# os.system('hg rm '+fullname)
|
||||||
|
# os.system('rm '+fullname)
|
||||||
Reference in New Issue
Block a user