[gen] String.inlineEdit can now be a method; [gen] mail.py: more log info when something is wrong.

This commit is contained in:
Gaetan Delannay 2015-01-27 12:10:38 +01:00
parent cd29eccd41
commit bfb10675de
2 changed files with 24 additions and 10 deletions

View file

@ -151,10 +151,11 @@ class String(Field):
pxView = Px('''
<x var="fmt=field.format; isUrl=field.isUrl;
languages=field.getAttribute(zobj, 'languages');
languages=field.getAttribute(obj, 'languages');
multilingual=len(languages) &gt; 1;
mLayout=multilingual and field.getLanguagesLayout('view');
mayAjaxEdit=not showChanges and field.inlineEdit and \
inlineEdit=field.getAttribute(obj, 'inlineEdit');
mayAjaxEdit=not showChanges and inlineEdit and \
(layoutType != 'cell') and \
zobj.mayEdit(field.writePermission)">
<x if="field.isSelect">
@ -405,7 +406,8 @@ class String(Field):
# other). Specify here a dict whose keys are layouts ("edit", "view")
# and whose values are either "horizontal" or "vertical".
self.languagesLayouts = languagesLayouts
# When format in XHTML, can the field be inline-edited (ckeditor)?
# When format in XHTML, can the field be inline-edited (ckeditor)? A
# method can be specified.
self.inlineEdit = inlineEdit
# The following field has a direct impact on the text entered by the
# user. It applies a transformation on it, exactly as does the CSS

View file

@ -17,11 +17,14 @@ class MailConfig:
self.fromName = fromName
# The email that will appear in the "from" part of the messages
self.fromEmail = fromEmail
# The SMTP server address
self.server = server
# The SMTP server port
self.port = port
# Optional credentials to the SMTP server.
# The SMTP server address and port
if ':' in server:
self.server, port = server.split(':')
self.port = int(port)
else:
self.server = server
self.port = int(port) # That way, people can specify an int or str
# Optional credentials to the SMTP server
self.login = login
self.password = password
# Is this server connection enabled ?
@ -32,6 +35,13 @@ class MailConfig:
if self.fromName: return '%s <%s>' % (self.fromName, self.fromEmail)
return self.fromEmail
def __repr__(self):
'''Short string representation of this mail config, for logging and
debugging purposes.'''
res = '%s:%d' % (self.server, self.port)
if self.login: res += ' (login as %s)' % self.login
return res
# ------------------------------------------------------------------------------
def sendMail(config, to, subject, body, attachments=None, log=None):
'''Sends a mail, via the smtp server defined in the p_config (an instance of
@ -111,7 +121,9 @@ def sendMail(config, to, subject, body, attachments=None, log=None):
log('could not send mail to some recipients. %s' % str(res),
type='warning')
except smtplib.SMTPException, e:
if log: log('mail sending failed: %s' % str(e), type='error')
if log:
log('%s: mail sending failed (%s)' % (config, str(e)), type='error')
except socket.error, se:
if log: log('mail sending failed: %s' % str(se), type='error')
if log:
log('%s: mail sending failed (%s)' % (config, str(e)), type='error')
# ------------------------------------------------------------------------------