Merge branch 'master' of github.com:web2py/web2py

This commit is contained in:
mdipierro
2016-12-20 15:49:44 -06:00
7 changed files with 37 additions and 21 deletions
+1
View File
@@ -317,6 +317,7 @@
'beforeSend': function (xhr, settings) { 'beforeSend': function (xhr, settings) {
xhr.setRequestHeader('web2py-component-location', document.location); xhr.setRequestHeader('web2py-component-location', document.location);
xhr.setRequestHeader('web2py-component-element', target); xhr.setRequestHeader('web2py-component-element', target);
web2py.fire(element, 'w2p:componentBegin', [xhr, settings], target);
return web2py.fire(element, 'ajax:beforeSend', [xhr, settings], target); //test a usecase, should stop here if returns false return web2py.fire(element, 'ajax:beforeSend', [xhr, settings], target); //test a usecase, should stop here if returns false
}, },
'success': function (data, status, xhr) { 'success': function (data, status, xhr) {
@@ -317,6 +317,7 @@
'beforeSend': function (xhr, settings) { 'beforeSend': function (xhr, settings) {
xhr.setRequestHeader('web2py-component-location', document.location); xhr.setRequestHeader('web2py-component-location', document.location);
xhr.setRequestHeader('web2py-component-element', target); xhr.setRequestHeader('web2py-component-element', target);
web2py.fire(element, 'w2p:componentBegin', [xhr, settings], target);
return web2py.fire(element, 'ajax:beforeSend', [xhr, settings], target); //test a usecase, should stop here if returns false return web2py.fire(element, 'ajax:beforeSend', [xhr, settings], target); //test a usecase, should stop here if returns false
}, },
'success': function (data, status, xhr) { 'success': function (data, status, xhr) {
+1
View File
@@ -317,6 +317,7 @@
'beforeSend': function (xhr, settings) { 'beforeSend': function (xhr, settings) {
xhr.setRequestHeader('web2py-component-location', document.location); xhr.setRequestHeader('web2py-component-location', document.location);
xhr.setRequestHeader('web2py-component-element', target); xhr.setRequestHeader('web2py-component-element', target);
web2py.fire(element, 'w2p:componentBegin', [xhr, settings], target);
return web2py.fire(element, 'ajax:beforeSend', [xhr, settings], target); //test a usecase, should stop here if returns false return web2py.fire(element, 'ajax:beforeSend', [xhr, settings], target); //test a usecase, should stop here if returns false
}, },
'success': function (data, status, xhr) { 'success': function (data, status, xhr) {
+5 -1
View File
@@ -438,7 +438,11 @@ def add_path_first(path):
def try_mkdir(path): def try_mkdir(path):
if not os.path.exists(path): if not os.path.exists(path):
try: try:
os.mkdir(path) if os.path.islink(path):
# path is a broken link, try to mkdir the target of the link instead of the link itself.
os.mkdir(os.path.realpath(path))
else:
os.mkdir(path)
except OSError as e: except OSError as e:
if e.strerror == 'File exists': # In case of race condition. if e.strerror == 'File exists': # In case of race condition.
pass pass
+15 -9
View File
@@ -951,12 +951,23 @@ def findT(path, language=DEFAULT_LANGUAGE):
Note: Note:
Must be run by the admin app Must be run by the admin app
""" """
from gluon.tools import Auth, Crud
lang_file = pjoin(path, 'languages', language + '.py') lang_file = pjoin(path, 'languages', language + '.py')
sentences = read_dict(lang_file) sentences = read_dict(lang_file)
mp = pjoin(path, 'models') mp = pjoin(path, 'models')
cp = pjoin(path, 'controllers') cp = pjoin(path, 'controllers')
vp = pjoin(path, 'views') vp = pjoin(path, 'views')
mop = pjoin(path, 'modules') mop = pjoin(path, 'modules')
def add_message(message):
if not message.startswith('#') and not '\n' in message:
tokens = message.rsplit('##', 1)
else:
# this allows markmin syntax in translations
tokens = [message]
if len(tokens) == 2:
message = tokens[0].strip() + '##' + tokens[1].strip()
if message and not message in sentences:
sentences[message] = message.replace("@markmin\x01", "")
for filename in \ for filename in \
listdir(mp, '^.+\.py$', 0) + listdir(cp, '^.+\.py$', 0)\ listdir(mp, '^.+\.py$', 0) + listdir(cp, '^.+\.py$', 0)\
+ listdir(vp, '^.+\.html$', 0) + listdir(mop, '^.+\.py$', 0): + listdir(vp, '^.+\.html$', 0) + listdir(mop, '^.+\.py$', 0):
@@ -970,15 +981,10 @@ def findT(path, language=DEFAULT_LANGUAGE):
message = safe_eval(item) message = safe_eval(item)
except: except:
continue # silently ignore inproperly formatted strings continue # silently ignore inproperly formatted strings
if not message.startswith('#') and not '\n' in message: add_message(message)
tokens = message.rsplit('##', 1) gluon_msg = [Auth.default_messages, Crud.default_messages]
else: for item in [x for m in gluon_msg for x in m.values() if x is not None]:
# this allows markmin syntax in translations add_message(item)
tokens = [message]
if len(tokens) == 2:
message = tokens[0].strip() + '##' + tokens[1].strip()
if message and not message in sentences:
sentences[message] = message.replace("@markmin\x01", "")
if not '!langcode!' in sentences: if not '!langcode!' in sentences:
sentences['!langcode!'] = ( sentences['!langcode!'] = (
DEFAULT_LANGUAGE if language in ('default', DEFAULT_LANGUAGE) else language) DEFAULT_LANGUAGE if language in ('default', DEFAULT_LANGUAGE) else language)
+13 -11
View File
@@ -4798,6 +4798,18 @@ class Auth(object):
class Crud(object): # pragma: no cover class Crud(object): # pragma: no cover
default_messages = dict(
submit_button = 'Submit',
delete_label = 'Check to delete',
record_created = 'Record Created',
record_updated = 'Record Updated',
record_deleted = 'Record Deleted',
update_log = 'Record %(id)s updated',
create_log = 'Record %(id)s created',
read_log = 'Record %(id)s read',
delete_log = 'Record %(id)s deleted',
)
def url(self, f=None, args=None, vars=None): def url(self, f=None, args=None, vars=None):
""" """
This should point to the controller that exposes This should point to the controller that exposes
@@ -4846,17 +4858,7 @@ class Crud(object): # pragma: no cover
settings.lock_keys = True settings.lock_keys = True
messages = self.messages = Messages(current.T) messages = self.messages = Messages(current.T)
messages.submit_button = 'Submit' messages.update(Crud.default_messages)
messages.delete_label = 'Check to delete'
messages.record_created = 'Record Created'
messages.record_updated = 'Record Updated'
messages.record_deleted = 'Record Deleted'
messages.update_log = 'Record %(id)s updated'
messages.create_log = 'Record %(id)s created'
messages.read_log = 'Record %(id)s read'
messages.delete_log = 'Record %(id)s deleted'
messages.lock_keys = True messages.lock_keys = True
def __call__(self): def __call__(self):
@@ -216,6 +216,7 @@ fi
/etc/init.d/nginx start /etc/init.d/nginx start
systemctl start emperor.uwsgi.service systemctl start emperor.uwsgi.service
systemctl enable emperor.uwsgi.service
echo <<EOF echo <<EOF
you can stop uwsgi and nginx with you can stop uwsgi and nginx with