[gen] String.inlineEdit can now be a method; [gen] mail.py: more log info when something is wrong.
This commit is contained in:
parent
cd29eccd41
commit
bfb10675de
|
@ -151,10 +151,11 @@ class String(Field):
|
||||||
|
|
||||||
pxView = Px('''
|
pxView = Px('''
|
||||||
<x var="fmt=field.format; isUrl=field.isUrl;
|
<x var="fmt=field.format; isUrl=field.isUrl;
|
||||||
languages=field.getAttribute(zobj, 'languages');
|
languages=field.getAttribute(obj, 'languages');
|
||||||
multilingual=len(languages) > 1;
|
multilingual=len(languages) > 1;
|
||||||
mLayout=multilingual and field.getLanguagesLayout('view');
|
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 \
|
(layoutType != 'cell') and \
|
||||||
zobj.mayEdit(field.writePermission)">
|
zobj.mayEdit(field.writePermission)">
|
||||||
<x if="field.isSelect">
|
<x if="field.isSelect">
|
||||||
|
@ -405,7 +406,8 @@ class String(Field):
|
||||||
# other). Specify here a dict whose keys are layouts ("edit", "view")
|
# other). Specify here a dict whose keys are layouts ("edit", "view")
|
||||||
# and whose values are either "horizontal" or "vertical".
|
# and whose values are either "horizontal" or "vertical".
|
||||||
self.languagesLayouts = languagesLayouts
|
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
|
self.inlineEdit = inlineEdit
|
||||||
# The following field has a direct impact on the text entered by the
|
# 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
|
# user. It applies a transformation on it, exactly as does the CSS
|
||||||
|
|
26
gen/mail.py
26
gen/mail.py
|
@ -17,11 +17,14 @@ class MailConfig:
|
||||||
self.fromName = fromName
|
self.fromName = fromName
|
||||||
# The email that will appear in the "from" part of the messages
|
# The email that will appear in the "from" part of the messages
|
||||||
self.fromEmail = fromEmail
|
self.fromEmail = fromEmail
|
||||||
# The SMTP server address
|
# The SMTP server address and port
|
||||||
self.server = server
|
if ':' in server:
|
||||||
# The SMTP server port
|
self.server, port = server.split(':')
|
||||||
self.port = port
|
self.port = int(port)
|
||||||
# Optional credentials to the SMTP server.
|
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.login = login
|
||||||
self.password = password
|
self.password = password
|
||||||
# Is this server connection enabled ?
|
# Is this server connection enabled ?
|
||||||
|
@ -32,6 +35,13 @@ class MailConfig:
|
||||||
if self.fromName: return '%s <%s>' % (self.fromName, self.fromEmail)
|
if self.fromName: return '%s <%s>' % (self.fromName, self.fromEmail)
|
||||||
return 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):
|
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
|
'''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),
|
log('could not send mail to some recipients. %s' % str(res),
|
||||||
type='warning')
|
type='warning')
|
||||||
except smtplib.SMTPException, e:
|
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:
|
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')
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue