1017 sourcedirs = [join(path, 'i18n') for path in self.cubes_path()] |
1017 sourcedirs = [join(path, 'i18n') for path in self.cubes_path()] |
1018 sourcedirs.append(self.i18n_lib_dir()) |
1018 sourcedirs.append(self.i18n_lib_dir()) |
1019 return i18n.compile_i18n_catalogs(sourcedirs, i18ndir, langs) |
1019 return i18n.compile_i18n_catalogs(sourcedirs, i18ndir, langs) |
1020 |
1020 |
1021 def sendmails(self, msgs): |
1021 def sendmails(self, msgs): |
1022 """msgs: list of 2-uple (message object, recipients)""" |
1022 """msgs: list of 2-uple (message object, recipients). Return False |
|
1023 if connection to the smtp server failed, else True. |
|
1024 """ |
1023 server, port = self['smtp-host'], self['smtp-port'] |
1025 server, port = self['smtp-host'], self['smtp-port'] |
1024 SMTP_LOCK.acquire() |
1026 SMTP_LOCK.acquire() |
1025 try: |
1027 try: |
1026 try: |
1028 try: |
1027 smtp = SMTP(server, port) |
1029 smtp = SMTP(server, port) |
1028 except Exception, ex: |
1030 except Exception, ex: |
1029 self.exception("can't connect to smtp server %s:%s (%s)", |
1031 self.exception("can't connect to smtp server %s:%s (%s)", |
1030 server, port, ex) |
1032 server, port, ex) |
1031 return |
1033 return False |
1032 heloaddr = '%s <%s>' % (self['sender-name'], self['sender-addr']) |
1034 heloaddr = '%s <%s>' % (self['sender-name'], self['sender-addr']) |
1033 for msg, recipients in msgs: |
1035 for msg, recipients in msgs: |
1034 try: |
1036 try: |
1035 smtp.sendmail(heloaddr, recipients, msg.as_string()) |
1037 smtp.sendmail(heloaddr, recipients, msg.as_string()) |
1036 except Exception, ex: |
1038 except Exception, ex: |
1037 self.exception("error sending mail to %s (%s)", |
1039 self.exception("error sending mail to %s (%s)", |
1038 recipients, ex) |
1040 recipients, ex) |
1039 smtp.close() |
1041 smtp.close() |
1040 finally: |
1042 finally: |
1041 SMTP_LOCK.release() |
1043 SMTP_LOCK.release() |
|
1044 return True |
1042 |
1045 |
1043 set_log_methods(CubicWebConfiguration, logging.getLogger('cubicweb.configuration')) |
1046 set_log_methods(CubicWebConfiguration, logging.getLogger('cubicweb.configuration')) |
1044 |
1047 |
1045 # alias to get a configuration instance from an instance id |
1048 # alias to get a configuration instance from an instance id |
1046 instance_configuration = CubicWebConfiguration.config_for |
1049 instance_configuration = CubicWebConfiguration.config_for |