Skip to content

Commit

Permalink
Merge branch 'master' of github.com:web2py/web2py
Browse files Browse the repository at this point in the history
  • Loading branch information
mdipierro committed Dec 20, 2016
2 parents 28b0385 + ac9bccb commit ce0c5f2
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 21 deletions.
1 change: 1 addition & 0 deletions applications/admin/static/js/web2py.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@
'beforeSend': function (xhr, settings) {
xhr.setRequestHeader('web2py-component-location', document.location);
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
},
'success': function (data, status, xhr) {
Expand Down
1 change: 1 addition & 0 deletions applications/examples/static/js/web2py.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@
'beforeSend': function (xhr, settings) {
xhr.setRequestHeader('web2py-component-location', document.location);
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
},
'success': function (data, status, xhr) {
Expand Down
1 change: 1 addition & 0 deletions applications/welcome/static/js/web2py.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@
'beforeSend': function (xhr, settings) {
xhr.setRequestHeader('web2py-component-location', document.location);
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
},
'success': function (data, status, xhr) {
Expand Down
6 changes: 5 additions & 1 deletion gluon/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,11 @@ def add_path_first(path):
def try_mkdir(path):
if not os.path.exists(path):
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:
if e.strerror == 'File exists': # In case of race condition.
pass
Expand Down
24 changes: 15 additions & 9 deletions gluon/languages.py
Original file line number Diff line number Diff line change
Expand Up @@ -951,12 +951,23 @@ def findT(path, language=DEFAULT_LANGUAGE):
Note:
Must be run by the admin app
"""
from gluon.tools import Auth, Crud
lang_file = pjoin(path, 'languages', language + '.py')
sentences = read_dict(lang_file)
mp = pjoin(path, 'models')
cp = pjoin(path, 'controllers')
vp = pjoin(path, 'views')
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 \
listdir(mp, '^.+\.py$', 0) + listdir(cp, '^.+\.py$', 0)\
+ listdir(vp, '^.+\.html$', 0) + listdir(mop, '^.+\.py$', 0):
Expand All @@ -970,15 +981,10 @@ def findT(path, language=DEFAULT_LANGUAGE):
message = safe_eval(item)
except:
continue # silently ignore inproperly formatted strings
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", "")
add_message(message)
gluon_msg = [Auth.default_messages, Crud.default_messages]
for item in [x for m in gluon_msg for x in m.values() if x is not None]:
add_message(item)
if not '!langcode!' in sentences:
sentences['!langcode!'] = (
DEFAULT_LANGUAGE if language in ('default', DEFAULT_LANGUAGE) else language)
Expand Down
24 changes: 13 additions & 11 deletions gluon/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -4798,6 +4798,18 @@ def wikimenu(self):

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):
"""
This should point to the controller that exposes
Expand Down Expand Up @@ -4846,17 +4858,7 @@ def __init__(self, environment, db=None, controller='default'):
settings.lock_keys = True

messages = self.messages = Messages(current.T)
messages.submit_button = 'Submit'
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.update(Crud.default_messages)
messages.lock_keys = True

def __call__(self):
Expand Down
1 change: 1 addition & 0 deletions scripts/setup-web2py-nginx-uwsgi-ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ fi

/etc/init.d/nginx start
systemctl start emperor.uwsgi.service
systemctl enable emperor.uwsgi.service

echo <<EOF
you can stop uwsgi and nginx with
Expand Down

0 comments on commit ce0c5f2

Please sign in to comment.