diff --git a/gen/mail.py b/gen/mail.py index 9ed0368..ed75b10 100644 --- a/gen/mail.py +++ b/gen/mail.py @@ -1,5 +1,5 @@ '''This package contains functions for sending email notifications.''' -import smtplib +import smtplib, socket from email.MIMEMultipart import MIMEMultipart from email.MIMEBase import MIMEBase from email.MIMEText import MIMEText @@ -50,6 +50,8 @@ def sendMail(tool, to, subject, body, attachments=None): if attachments: for fileName, fileContent in attachments: part = MIMEBase('application', 'octet-stream') + if fileContent.__class__.__name__ == 'FileWrapper': + fileContent = fileContent._zopeFile if hasattr(fileContent, 'data'): # It is a File instance coming from the database data = fileContent.data @@ -87,6 +89,8 @@ def sendMail(tool, to, subject, body, attachments=None): type='warning') except smtplib.SMTPException, e: tool.log('Mail sending failed: %s' % str(e), type='error') + except socket.error, se: + tool.log('Mail sending failed: %s' % str(se), type='error') # ------------------------------------------------------------------------------ def sendNotification(obj, transition, transitionName, workflow): diff --git a/gen/model.py b/gen/model.py index 9f92714..b5c4a52 100644 --- a/gen/model.py +++ b/gen/model.py @@ -223,6 +223,7 @@ class Tool(ModelClass): # Tool attributes def isManager(self): pass + def isManagerEdit(self): pass title = gen.String(show=False, page=gen.Page('main', show=False)) mailHost = gen.String(default='localhost:25') mailEnabled = gen.Boolean(default=False) @@ -249,7 +250,7 @@ class Tool(ModelClass): page=gen.Page('pages', show=isManager)) # Document generation page - dgp = {'page': gen.Page('documentGeneration', show=isManager)} + dgp = {'page': gen.Page('documentGeneration', show=isManagerEdit)} def validPythonWithUno(self, value): pass # Real method in the wrapper unoEnabledPython = gen.String(show=False,validator=validPythonWithUno,**dgp) openOfficePort = gen.Integer(default=2002, show=False, **dgp) diff --git a/gen/ui/template.pt b/gen/ui/template.pt index c2740bc..e8fd241 100644 --- a/gen/ui/template.pt +++ b/gen/ui/template.pt @@ -1,3 +1,4 @@ + diff --git a/gen/wrappers/ToolWrapper.py b/gen/wrappers/ToolWrapper.py index 23ba2f9..c6eab9f 100644 --- a/gen/wrappers/ToolWrapper.py +++ b/gen/wrappers/ToolWrapper.py @@ -34,6 +34,10 @@ class ToolWrapper(AbstractWrapper): '''Some pages on the tool can only be accessed by God.''' if self.user.has_role('Manager'): return 'view' + def isManagerEdit(self): + '''Some pages on the tool can only be accessed by God, also in edit.''' + if self.user.has_role('Manager'): return True + podOutputFormats = ('odt', 'pdf', 'doc', 'rtf') def getPodOutputFormats(self): '''Gets the available output formats for POD documents.''' @@ -54,7 +58,11 @@ class ToolWrapper(AbstractWrapper): def getDiskFolder(self): '''Returns the disk folder where the Appy application is stored.''' - return self.o.getProductConfig().diskFolder + return self.o.config.diskFolder + + def getClass(self, zopeName): + '''Gets the Appy class corresponding to technical p_zopeName.''' + return self.o.getAppyClass(zopeName) def getAttributeName(self, attributeType, klass, attrName=None): '''Some names of Tool attributes are not easy to guess. For example, diff --git a/shared/utils.py b/shared/utils.py index 44160e6..d5331a1 100644 --- a/shared/utils.py +++ b/shared/utils.py @@ -281,23 +281,20 @@ def cleanXhtml(s, keepStyles=False): return s # ------------------------------------------------------------------------------ -toLower = {'Ç':'ç','Ù':'ù','Û':'û','Ü':'ü','Î':'î','Ï':'ï','Ô':'ô','Ö':'ö', - 'É':'é','È':'è','Ê':'ê','Ë':'ë','À':'à','Â':'â','Ä':'ä'} -toUpper = {'ç':'Ç','ù':'Ù','û':'Û','ü':'Ü','î':'Î','ï':'Ï','ô':'Ô','ö':'Ö', - 'é':'É','è':'È','ê':'Ê','ë':'Ë','à':'À','â':'Â','ä':'Ä'} - def lower(s): '''French-accents-aware variant of string.lower.''' + isUnicode = isinstance(s, unicode) + if not isUnicode: s = s.decode('utf-8') res = s.lower() - for upp, low in toLower.iteritems(): - if upp in res: res = res.replace(upp, low) + if not isUnicode: res = res.encode('utf-8') return res def upper(s): '''French-accents-aware variant of string.upper.''' + isUnicode = isinstance(s, unicode) + if not isUnicode: s = s.decode('utf-8') res = s.upper() - for low, upp in toUpper.iteritems(): - if low in res: res = res.replace(low, upp) + if not isUnicode: res = res.encode('utf-8') return res # ------------------------------------------------------------------------------